I'm using a RecyclerView for a list. I've a found a really nice solution to give the list click feedback and ripple (on Lollipop). Basically I'm giving my row layout the attribute:
android:background="?android:attr/selectableItemBackground"
And everything is fine, except that I need a different background color for my list (default state). How can I override just the basic state background (not clicked) giving it a different color?
selectableItemBackground is the name of an attribute in your app's theme (usually in styles. xml ). You might not be setting a value for it in your theme, but it might have a value in the parent theme that yours extends from, so your theme has that value as well.
The touch feedback in Android is a must whenever the user clicks on the item or button ripple effect when clicking on the same, gives confidence to the user that the button has been clicked so that they can wait for the next interaction of the app.
This will give custom background color and default grey ripple effect:
android:background="@color/YourCustomColor"
android:foreground="?android:attr/selectableItemBackground"
You can try this: it helped me a lot, this way we can use the background we want and keep the great click feedback. Wrap your row view inside a frame layout.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With