[英]List View not displaying divider for 1st item with Text View on top
I have a Text View on top of list view but the list is not displaying the header divider line, but if i remove the textview and keep only the list view then the header divider line is displaying. 我在列表视图的顶部有一个文本视图,但是列表未显示标题分隔线,但是如果我删除了textview并仅保留列表视图,则会显示标题分隔线。
i have tried this too : HeaderDividerEnabled : true
but not working. 我也尝试过这个: HeaderDividerEnabled : true
但不起作用。
<TextView
android:id="@+id/tv"
android:visibility="gone"
android:layout_below="@+id/header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="center_horizontal"
android:textColor="#000000"
android:textSize="@dimen/text_size"/>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tv"
android:layout_marginTop="2dp"
android:cacheColorHint="#00000000"
android:overScrollMode="never"
android:divider="@color/black"
android:dividerHeight="0.8dp"
android:listSelector="@drawable/selector">
</ListView>
That is not what android:headerDividersEnabled is supposed to do. 那不是android:headerDividersEnabled应该做的。 It means that if you are adding a list header whether that header needs to be separated by a divider or not. 这意味着,如果要添加列表标题,则是否需要用分隔符分隔该标题。
Here is a working example: stackoverflow.com/a/8819402/915756 这是一个工作示例:stackoverflow.com/a/8819402/915756
hope this helps 希望这可以帮助
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hi Goofy"
android:textSize="30sp" />
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:cacheColorHint="#00000000"
android:background="@drawable/border"
android:divider="@android:color/background_dark"
android:dividerHeight="0.8dp"
android:entries="@array/hh"
android:footerDividersEnabled="true"
android:headerDividersEnabled="true"
android:overScrollMode="never" >
</ListView>
</LinearLayout>
/// border /// 边界
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<!-- use this for transparent -->
<!-- <solid android:color="#00000000" /> -->
<!-- use this for a background colour -->
<solid android:color="#FFF" />
<stroke android:width="2dip" android:color="#FF0000" />
</shape>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.