我想在用户点击任何项目时更改卡片项目的颜色,但没有任何反应..为什么?
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="3dp"
android:layout_marginTop="9dp"
android:layout_marginLeft="9dp"
android:layout_marginRight="9dp"
card_view:cardElevation="0.01dp"
android:layout_marginBottom="0dp"
android:foreground="@drawable/card_foreground">
请试试这个..
添加 android:clickable="true"
和 android:focusable="true"
和
将 android:foreground 更改为 android:foreground="?android:selectableItemBackground"
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
card_view:cardCornerRadius="3dp"
android:layout_marginTop="9dp"
android:layout_marginLeft="9dp"
android:layout_marginRight="9dp"
card_view:cardElevation="0.01dp"
android:layout_marginBottom="0dp"
android:clickable="true"
android:focusable="true"
android:foreground="?android:selectableItemBackground" >
</android.support.v7.widget.CardView>