2014-10-05 57 views
-1

在eclipse中所有看起来都不错,但在行和列表视图之间的设备上有很大的距离。 如何删除列表和行之间的距离? 这里的XML布局:将行绑定到ListView的末尾

<?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> 

in eclipseon device

回答

0

您已设置查看里面的margin_top = “18dp”。 删除已设置为列表视图的布局权重。

+0

谢谢!你救了我。 – 2014-10-06 11:55:14

+0

快乐我可以帮助你。 – Harsha 2014-10-06 12:20:32

0

您可以使用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="[email protected]/top_line" 
android:layout_width="match_parent" 
android:layout_height="6dp" 
android:background="@drawable/line_top" 
android:layout_below="[email protected]/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="[email protected]/top_line" 
    > 
</ListView> 
<View 
android:layout_width="match_parent" 
android:layout_height="6dp" 
    android:background="@drawable/line_bottom" 
android:layout_below="[email protected]/mainList" 
android:layout_marginLeft="20dp" 
android:layout_marginRight="20dp" 
android:layout_marginTop="18dp" 
android:layout_marginBottom="18dp" 
    /> 
</RelativeLayout > 
+0

也是好方法。谢谢您的回答。 – 2014-10-06 11:56:31