为Android可点击控件设置涟漪/水波纹效果

只需要在xml中给指定控件加上

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

即可。

<androidx.cardview.widget.CardView
    android:id="@+id/card"
    android:clickable="true"
    android:longClickable="true"
    android:foreground="?android:attr/selectableItemBackground"
    >
androidx.cardview.widget.CardView>

你可能感兴趣的:(Android,android,android,studio,ide)