RecyclerView + CardView + Touch feedback

前端 未结 5 1874
一整个雨季
一整个雨季 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 11:14

    Background:

    The CardView ignores android:background in favor of app:cardBackground which can only be color. The border and shadow are in fact part of the background so you cannot set your own.

    Solution:

    Make the layout inside the CardView clickable instead of the card itself. You already wrote both attributes needed for this layout:

    android:clickable="true"
    android:background="?android:selectableItemBackground"
    

提交回复
热议问题