I use a RecyclerView and a simple item layout consisting of a ConstraintLayout holding the text elements of each item. I want to set the background of all items while
- showing a ripple effect when clicked.
- visualizing when the view is active.
- being able to set the colors. (optional, if it really has to be)
The minimum SDK version is 21 and is allowed to be raised if required.
What I tried:
- Using
@android:drawable/list_selector_backgroundis not customizable and did not show a ripple. - Using
?selectableItemBackgroundor?selectableItemBackgroundBorderlessdoes not work, it throws an exception at runtime (Failed to resolve attribute [...]). I do have the design support library placed in my gradle script, or now thecom.google.android.materialpackage. Prependingandroid:attr/produced the same error. - Using a
StateListDrawableto build it all by myself using many<ripple>Drawables seemed overly complicated since I did not want to reproduce the whole functionality of above features.