Android 列表选择器在自定义列表视图中不可见

2023-12-12

我制作了一个包含图像和文本视图的自定义列表。设置样式时,选择器不可见。使用 setTheme(R.style.rose) 调用样式;在 Listactivity 的 create 方法中作为第一次调用。 但是,如果没有颜色用作背景(或样式中的背景线被注释),则橙色选择器可见。但当背景是

列表选择器

<item   android:state_focused="true"
        android:state_pressed="true" 
        android:drawable="@drawable/list_selector_background_transition" />

<item   android:state_pressed="true" 
        android:drawable="@drawable/list_selector_background_pressed" />

<item   android:state_focused="true" 
        android:drawable="@drawable/list_selector_background_focus" />

style

<style name="rose">
    <item name="android:textColor">@color/pink</item>
    <item name="android:background">@color/rose</item>
    <item name="android:cacheColorHint">@color/rose</item>

    <item name="android:listSelector">@drawable/listitem_selector</item>  
</style>

Android 首先绘制 ListView 背景以及分隔线。然后,系统绘制列表选择器。最后,ListView 渲染其上的所有 itemview。因此,将不透明背景设置为 itemviews 时,列表选择器将永远不可见

http://android.cyrimottier.com/?p=454

enter image description here

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Android 列表选择器在自定义列表视图中不可见 的相关文章

随机推荐