After I searched for a while, I could not find the answer to this question ...
I have a recycler view with elements that, when selected, have a red background and white text (previously the background is white and the text is black). For this, I use a selector.
I recently tried to add a ripple effect, but if I don’t click on an element, the background of the element will immediately turn red without ripple. I assume this is because the state of the state_selected selector overrides the ripple to sate_pressed?
Does anyone know if there is a way around this? Here is the selector code I'm using:
<?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="@android:color/holo_red_dark" > <item> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/ripple" android:state_pressed="true"/> <item android:drawable="@android:color/holo_red_dark" android:state_selected="true"/> <item android:drawable="@android:color/white"/> </selector> </item> </ripple>
Thanks in advance!
android android-5.0-lollipop android-recyclerview ripple rippledrawable
Multij
source share