RecyclerView + CardView + Touch feedback

前端 未结 5 1806
一整个雨季
一整个雨季 2021-02-02 10:17

Has anybody solved the mystery of the CardView without touch feedback when it\'s inside a RecyclerView?

I have a RecyclerView with a bu

5条回答
  •  星月不相逢
    2021-02-02 10:58

    Solution 1

    As @Eugen proposed, you can make the layout inside CardView clickable, so then you can use android:background:

    
    

    Solution 2

    If you don't want to lose the item click listener by making the layout inside CardView clickable, you can use android:foreground:

    
    

    Extra: you can use "?attr/selectableItemBackgroundBorderless" instead of "?attr/selectableItemBackground" if you don't want the rectangle mask.

提交回复
热议问题