Android的listselector自定义列表视图中不可见 [英] Android listselector not visible in custom listview

查看:302
本文介绍了Android的listselector自定义列表视图中不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经具有图像和TextView中的自定义列表。在设定的样式,选择是不可见的。风格是使用setTheme(R.style.rose)调用;在创建Listactivity的方法,第一个电话。 但是,如果没有颜色作为背景(或风格背景行注释),那么橙色选择是可见的。但不是当背景

listSelector     

 <项目安卓state_focused =真
        机器人:STATE_ pressed =真
        机器人:可绘制=@可绘制/ list_selector_background_transition/>

<项目的android:STATE_ pressed =真
        机器人:可绘制=@可绘制/ list_selector_background_ pressed/>

<项目安卓state_focused =真
        机器人:可绘制=@可绘制/ list_selector_background_focus/>
 

风格

 <样式名称=玫瑰>
    <项目名称=机器人:文字颜色> @色/粉色< /项目>
    <项目名称=机器人:背景> @色/玫瑰< /项目>
    <项目名称=机器人:cacheColorHint> @色/玫瑰< /项目>

    <项目名称=机器人:listSelector> @可绘制/ listitem_selector< /项目>
< /风格>
 

解决方案

Android的第一个绘制ListView的背景以及分频器。然后,系统绘制列表选择器。最后,ListView控件呈现最重要的是所有itemviews。因此,该列表选择将永远与不透明的背景设置为itemviews可见

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

I have made a custom list having image and textview. On setting the styles, the selector is not visible. The style is invoked using setTheme(R.style.rose); in create method of Listactivity as the first call. However if no color is used as background (or background line in style is commented) then the orange selector is visible. But not when the background is

listSelector

<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 first draws the ListView background as well as the dividers. Then, the system draws the list selector. Finally, ListView renders all itemviews on top of that. So the list selector will never be visible with opaque background set to itemviews

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

这篇关于Android的listselector自定义列表视图中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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