【问题标题】:Tie the line to the end of ListView将线系到 ListView 的末尾
【发布时间】:2014-10-05 18:01:32
【问题描述】:

在eclipse中一切看起来都不错,但是在设备上line和listview之间有很大的距离。 如何删除列表和行之间的距离? 这里是xml布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/gradient"
    android:orientation="vertical" >   
        <TextView
            android:id="@+id/reminder"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
           />        
    <View 
     android:layout_width="match_parent"
     android:layout_height="6dp"
     android:background="@drawable/line_top"
     android:layout_marginLeft="20dp"
     android:layout_marginRight="20dp"
     android:layout_marginTop="18dp"     
      />
    <ListView
        android:id="@+id/mainList"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_weight="0.91" 
        >   
    </ListView>
    <View 
     android:layout_width="match_parent"
     android:layout_height="6dp"
      android:background="@drawable/line_bottom"
     android:layout_marginLeft="20dp"
     android:layout_marginRight="20dp"
     android:layout_marginTop="18dp"
     android:layout_marginBottom="18dp"  
      />
</LinearLayout>

!

【问题讨论】:

    标签: android xml eclipse listview distance


    【解决方案1】:

    您已在该视图中设置了 margin_top="18dp"。 移除您设置为 listview 的布局权重。

    【讨论】:

    • 谢谢!你救了我。
    • 很高兴能帮到你。
    【解决方案2】:

    你可以改用relaytiveLayout:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/gradient"
    android:orientation="vertical" >   
        <TextView
            android:id="@+id/reminder"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:align_parentTop="true"
            android:gravity="center"
           />        
    <View 
     android:id="+@id/top_line"
     android:layout_width="match_parent"
     android:layout_height="6dp"
     android:background="@drawable/line_top"
     android:layout_below="+@id/reminder"
     android:layout_marginLeft="20dp"
     android:layout_marginRight="20dp"
     android:layout_marginTop="18dp"     
      />
    <ListView
        android:id="@+id/mainList"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_below="+@id/top_line"
        >   
    </ListView>
    <View 
     android:layout_width="match_parent"
     android:layout_height="6dp"
      android:background="@drawable/line_bottom"
     android:layout_below="+@id/mainList"
     android:layout_marginLeft="20dp"
     android:layout_marginRight="20dp"
     android:layout_marginTop="18dp"
     android:layout_marginBottom="18dp"  
      />
    </RelativeLayout >
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-26
      • 1970-01-01
      • 1970-01-01
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多