Touch feedback with RecyclerView and CardView Touch feedback with RecyclerView and CardView android android

Touch feedback with RecyclerView and CardView


Assuming you are using Material/Appcompat theme and Lollipop,I got this to work by making the CardView have the following attributes:

android:focusable="true"android:clickable="true"android:foreground="?android:attr/selectableItemBackground"


CardLayout is just a subclass of ViewGroup, So setting:

android:background="?android:attr/selectableItemBackground"

should do the trick.

UPDATE:

(looks like you are trying to use a custom ripple color.)

Try using a ripple drawable with custom color as the background (I haven't used this, So I cannot verify this behavior.) see: the documentation or this question to get you started.


for me:

android:background="?android:attr/selectableItemBackground"

made it finally work.see background of recyclerView / content behind the item, and also see the ripple effect used with recyclerView.