Skip to content Skip to sidebar Skip to footer

Recyclerview Onitemclick Effect In L

Maybe this question has been asked before, but I couldn't find a precise answer. I have implemented the RecyclerView widget as a list in my L test application and I want to get the

Solution 1:

Sandra's answer didn't work for me. I needed one more property in my list item layout:

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

Note: if you get an error when pasting in the last line, then your android app is set on version 10 or below. Just right click on the error in Android Studio and set it so it will create a v11 version of your layout as well. Then, in the original layout, make sure to delete

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

This is because the animation isn't supported in v10 versions of android or lower. With these two layout files set up, the animation will correctly show in v11+ versions of Android and of course it won't be shown in lower versions.

(or just increase the minSdkVersion version of your app to higher than 10)

Solution 2:

I made a silly mistake and did not put

android:clickable="true"android:focusable="true"

to my list item layout. I think this was not required pre L, but it doesn't matter because that was the problem in this case.

Solution 3:

android:clickable="true"android:focusable="true"

these lines are no longer used. just adding

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

working for click effect.

Post a Comment for "Recyclerview Onitemclick Effect In L"