卡片不显示视觉反馈
Cards dont show visual feedback
我有一个装满卡片的回收适配器。卡本身工作正常。但是,当我单击卡片时,它不会显示任何视觉反馈。我缺少什么吗?我也很感激有关材料设计动画的教程。 android 开发者网站并没有真正打破现状。
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:clickable="true"
android:background="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="4dp"
android:layout_margin="5dp">
<RelativeLayout
android:id="@+id/cardBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary">
<TextView
android:id="@+id/cardname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textColor="@color/white"
android:gravity="center_horizontal"
android:textStyle="bold"
android:textSize="35sp"/>
<TextView
android:id="@+id/cardtime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cardname"
android:textColor="@color/white"
android:gravity="center_horizontal"
android:textStyle="bold"
android:textSize="15sp"/>
</RelativeLayout>
我可以通过更改
来实现视觉反馈
android:background="?android:attr/selectableItemBackgroundBorderless"
到
android:foreground="?android:attr/selectableItemBackgroundBorderless"
卡片视图中
我有一个装满卡片的回收适配器。卡本身工作正常。但是,当我单击卡片时,它不会显示任何视觉反馈。我缺少什么吗?我也很感激有关材料设计动画的教程。 android 开发者网站并没有真正打破现状。
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:clickable="true"
android:background="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="4dp"
android:layout_margin="5dp">
<RelativeLayout
android:id="@+id/cardBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorPrimary">
<TextView
android:id="@+id/cardname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textColor="@color/white"
android:gravity="center_horizontal"
android:textStyle="bold"
android:textSize="35sp"/>
<TextView
android:id="@+id/cardtime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cardname"
android:textColor="@color/white"
android:gravity="center_horizontal"
android:textStyle="bold"
android:textSize="15sp"/>
</RelativeLayout>
我可以通过更改
来实现视觉反馈android:background="?android:attr/selectableItemBackgroundBorderless"
到
android:foreground="?android:attr/selectableItemBackgroundBorderless"
卡片视图中