Custom selectableItemBackground
I am using RecyclerView for a list box. I found a really good solution to give feedback and click on the list (on Lollipop). Basically I give my row layout to 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 main background of the state (not clicked) by giving it a different color?
source to share
You can try this: it helped me a lot, so we can use whatever background we want and keep great click-through feedback. Wrap the row view inside a frame layout.
source to share
Are you using CardViews
in RecyclerView
? If so, programmatically use .setCardBackgroundColor()
in holder
for each CardView
. Alternatively, you can wrap everything in a simple dummy FrameLayout
(with android: id) in CardView
and change that layout programmatically when you bind ViewHolders
.
source to share