android:headerDividersEnabled 不工作

标签 android listview header divider

我想在 ListView(位于 RelativeLayout)的顶部有一个分隔线,但是当我尝试使用它时,我只得到底部分隔线:

<ListView
        android:id="@+id/last_contacts_picked_list"
        android:headerDividersEnabled="true"
        android:footerDividersEnabled="true"
        android:paddingTop="50dp"
        android:dividerHeight="5dp"
        android:layout_marginTop="50dp"
        android:divider="@android:drawable/divider_horizontal_textfield"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="..."
        android:layout_alignLeft="..."
        android:layout_alignRight="..."
        android:layout_below="..."
         />

我有这样的东西:

http://i051.radikal.ru/1211/4f/a408db5e717f.png

为什么它也没有标题分隔符?

最佳答案

那不是什么android:headerDividersEnabled应该做的。这意味着如果您要添加列表标题,则该标题是否需要用分隔符分隔。

对于您的问题,只需使用带有分隔线的 ImageView 的线性布局作为源,然后是 ListView。希望这会有所帮助。

关于android:headerDividersEnabled 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13235710/

相关文章:

android - ListView 项目的自定义监听器

MySQL:动态导出标题位于顶部的 CSV 文件

c - 在 C 中抽象类型实现

android - RecyclerView Viewholder 重用

Android 手机 - 如何处理间歇性连接

android - 当用户按下设备音量键时,seekbar 拇指位置发生变化

android - 如何在 Android 10、Target API 29 中从设备的共享存储(根目录)读取现有文件?

.net - 像 ObjectListView 这样的免费控件?

android - 如何在 Android 的 ListView 中添加 3 个按钮?

jquery - 如何修复折叠到导航栏的故障标题