2014-11-05 60 views
0

我创建了一个列表视图与25dp填充如何使列表项在列表视图的填充后可见?

<ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:divider="@null" 
     android:dividerHeight="25dp" 
     android:padding="20dp" 
     android:scrollbars="none"></ListView> 

这是列表视图的外观

enter image description here

当我向下滚动列表,填充将超过列表项

enter image description here

我可以使列表视图的边框内的列表视图可见范围,不是在listview的内部填充?


列表项XML

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="#fff"> 


    <ImageView 
      android:id="@+id/button_history_list_item_one_function" 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:layout_centerVertical="true" 
      android:layout_margin="20dp" 
     android:src="@drawable/ic_launcher"/> 


    <LinearLayout android:layout_width="100dp" 
        android:layout_height="match_parent" 
        android:orientation="vertical" 
        android:layout_alignParentRight="true" 
     android:background="@drawable/left_border" 
     android:padding="10dp" 
        > 

    </LinearLayout> 

</RelativeLayout> 

此图片显示了我想要

enter image description here

+0

删除'android:padding =“20dp”' – 2014-11-05 06:27:12

+0

你可以把listitem的XML? – 2014-11-05 06:29:37

+0

如果我删除了填充,那么在列表的开始和结尾处都没有空格,如果在listitem和listview之间没有填充,它看起来不太好 – 2014-11-05 06:34:02

回答

0

使用的保证金,而不是填充

<ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:divider="@null" 
     android:layout_margin="20dp" 
     android:scrollbars="none"></ListView> 

替代方式 - 如果填充对您很重要,请在列表视图内使用填充左右间距,并使用边距顶部&底部。

<ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:divider="@null" 
     android:layout_marginTop="20dp" 
     android:layout_marginBottom="20dp" 
     android:paddingLeft="20dp" 
     android:paddingRight="20dp" 
     android:scrollbars="none"></ListView>