Thinkcomplete
Thinkcomplete

Reputation: 181

Android listselector not visible in custom listview

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>

Upvotes: 2

Views: 3783

Answers (1)

Jiang Qi
Jiang Qi

Reputation: 4448

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

enter image description here

Upvotes: 11

Related Questions