Android 5 中未显示 ListView 分隔线 [英] ListView divider not showing in Android 5

查看:21
本文介绍了Android 5 中未显示 ListView 分隔线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的列表视图,我为它定义了一个用于分隔线的自定义可绘制对象.我已将分隔高度定义为 1dp.列表视图位于片段内.

I have a simple listview for which I have defined a custom drawable for the divider. I have defined the divider height to be 1dp. The listview is within a fragment.

<shape
    android:shape="line" >
    <stroke
        android:color="@color/custom_color" />

    <gradient android:height="1dp" />

</shape>

它适用于除 L 之外的所有 Android 版本.

It works great for all Android versions except L.

有什么我遗漏的吗?

推荐答案

你应该使用 android:shape="rectangle" 而不是 android:shape="line"使其适用于每个 android 版本......(也将 stroke 更改为 solid)

You should use android:shape="rectangle" instead of android:shape="line" to make it work on every android version... (also change stroke to solid)

<shape
    android:shape="rectangle" >
    <solid android:color="@color/custom_color" />
    <gradient android:height="1dp" />
</shape>

玩得开心!

这篇关于Android 5 中未显示 ListView 分隔线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆