2014-11-05 72 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>