Search code examples
androidlistviewselectorripple

Default Ripple Effect disapears when using Selector


I have a ListView which hast by DEFAULT the normal android ripple effect.When I touch an element it is showing the animation. I didn't add anything in my xml code for this.

But now I want to use a selector for my parent Layout because I want to highlight it when I select it in my contextual action bar. And surprisingly the Ripple effect is gone ...

My XML for Selector is simple as that :

<selector xmlns:android="http://schemas.android.com/apk/res/android" >

    <item android:state_activated="true" android:drawable="@color/listview_highlight"/>
    <item android:drawable="@color/listview_normal" />

</selector>

I found out that you can use

"< ripple >< /ripple > "

But that needs an Api min 21.

I want to set the animation to default like it was in the past.

How can I do this ?


Solution

  • Finally I found a solution by doing try / error. I just needed to add

    android:drawSelectorOnTop="true"

    To my ListView and Voilaa !
    Everything is working fine now , hopefully this post can help someone !