(圖中顯示圖片的 Item 是在Header、Foot View中的)
最近有一個需求, 需要在ListView 的 HeaderView中 添加多個View, 最後發現每個View中都有一條分割線。 效果如圖中第一張圖片!
本來以爲只要設置 android:headerDividersEnabled="false" 就可以讓Header中的分割線消失,但實際並非如此啊, 設置後如圖中第二張圖; 分割線確實消失了,但是位置還是留着.. 這可不行啊,不能滿足我的需求。
最後設置了 android:divider="@null", 然後爲ListView的 Item 視圖加了跟線, 算是基本滿足需求,不知道有沒有更好的方法, 如果有的話還希望大家可以告訴我。
- <?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="wrap_content"
- android:orientation="vertical" >
- <View
- android:layout_width="fill_parent"
- android:layout_height="1px"
- android:background="#d8d8d8" />
- <TextView
- android:id="@+id/text1"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:background="#747474"
- android:gravity="center_vertical"
- android:minHeight="?android:attr/listPreferredItemHeight"
- android:paddingLeft="6dip"
- android:textAppearance="?android:attr/textAppearanceLarge" />
- </LinearLayout>