简体   繁体   English

Android无法从列表视图项中删除底边距

[英]Android cannot remove bottom margin from list view items

在此处输入图片说明 I have been searching all through Stack and I can't seem to find anything that helps. 我一直在搜索Stack,但似乎找不到任何有用的东西。 I have made list views 200000 times.. I have a simple list view and no matter what I DO there is a bottom margin. 我已经制作了20万次列表视图。.我有一个简单的列表视图,无论我做什么,都有一个下边距。 even got rid of all my subviews and jsut had the main relativelayout in the list and no luck. 甚至摆脱了我所有的子视图,并且jsut在列表中具有主要的relativelayout,而且没有运气。 My xml is as follows: 我的xml如下:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android1:id="@+id/listItem"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:height="70dp"
   >

<LinearLayout
    android:id="@+id/daysHolder"
    android:layout_width="40dp"
    android:layout_height="71dp"
    android:background="@color/orange"
     android:layout_marginTop="0dp"
    android:layout_marginBottom="0dp"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"

    android:paddingTop="0dp"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/daysAway"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="13dp"
        android:fontFamily="Roboto"
        android:gravity="center"
        android:text="6"

        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/white"
        android:textSize="20sp" />

    <TextView
        android:id="@+id/days"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fontFamily="Roboto"
        android:gravity="center"
        android:layout_marginTop="7dp"
        android:text="Days"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/white"
        android:textSize="15sp" />
</LinearLayout>

<RelativeLayout
    android:id="@+id/infoHolder"
    android:layout_width="match_parent"
    android:layout_height="70dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="0dp"
    android:layout_marginTop="0dp"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"

    android:paddingTop="0dp" >

    <TextView
        android:id="@+id/eventLocation"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/BandName"
        android:layout_marginLeft="45dp"
        android:layout_marginTop="3dp"
        android:text="TextView"
        android:textSize="12sp" />

    <TextView
        android:id="@+id/Distance"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:gravity="right"
        android:text="TextView"
        android:textSize="9sp" />

    <TextView
        android:id="@+id/EventDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/eventLocation"
        android:layout_marginLeft="45dp"
        android:text="TextView"

        android:textSize="12sp" />

    <TextView
        android:id="@+id/BandName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="45dp"

        android:text="TextView" />
</RelativeLayout>

as you can see its nothing out of the ordinary. 如您所见,它与众不同。 But no matter what i have a 20px margin below each list item. 但是无论我在每个列表项下方有20px的边距是什么。

Am I doing somehting funky in my xml? 我在做一些时髦的XML吗?

this is my listview activity xml 这是我的listview活动xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
android:weightSum="1"
tools:context=".ListView" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="fill"
    android:orientation="vertical" >

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        android:layout_margin="0dp"
        android:layout_marginBottom="0dp"
        android:layout_marginLeft="0dp"
        android:layout_marginRight="0dp"
        android:layout_marginTop="0dp"
        android:layout_gravity="top"
        android:background="@color/white"
        android:padding="0dp" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="fitXY"
            android:src="@drawable/listlocal" />

        <ListView
            android:id="@+id/localShows"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="0dp"
            android:layout_marginBottom="0dp"
            android:layout_marginLeft="0dp"
            android:layout_marginRight="0dp"
            android:layout_marginTop="0dp"
            android:dividerHeight="0dp"
            android:background="#eaeaea"
            android:visibility="gone"
            android:padding="0dp" >
        </ListView>

    </FrameLayout>

</LinearLayout>

Why have you added this code? 为什么要添加此代码?

android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"

just remove it, it is useless. 只是删除它,它是没有用的。

Now, the answer. 现在,答案。 Your "marbin bottom" is your Distance textVew. 您的“ marbin bottom”是“距离” textVew。 It is below the EventDate textView. 它在EventDate textView下面。 Try this: 尝试这个:

<RelativeLayout
    android:id="@+id/infoHolder"
    android:layout_width="match_parent"
    android:layout_height="70dp">

    <TextView
        android:id="@+id/BandName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:text="TextView" />

    <TextView
        android:id="@+id/eventLocation"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:text="TextView"
        android:textSize="12sp" />

    <TextView
        android:id="@+id/EventDate"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="TextView"
        android:textSize="12sp" />

    <TextView
        android:id="@+id/Distance"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:gravity="right"
        android:layout_toRightOf="@+id/EventDate"
        android:text="TextView"
        android:textSize="9sp" />
</RelativeLayout>

do not forget to add your margins 不要忘记增加利润

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM