谁能向我解释一下如何在 CardView 中实现在 Google I/O 2014 上展示的一些视觉触摸反馈。
这是我在 XML 中使用 CardView 的方式,我可能缺少一些小东西,所以我只是想知道是否有人可以帮助我?
<!-- A CardView -->
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="@+id/CardView_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
card_view:cardCornerRadius="4dp"
android:elevation="2dp">
<LinearLayout
android:id="@+id/LinearLayout_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:onClick="RunSomeMethod"">
<!-- Main CardView Content In Here-->
</LinearLayout> </android.support.v7.widget.CardView>
最佳答案
API 11+:
将 android:foreground="?android:attr/selectableItemBackground"
添加到您的 CardView
元素中。
API 9+:
将 android:foreground="?selectableItemBackground"
添加到您的 CardView
元素中。
编辑:源自中心而不是触摸点的波纹是 known bug, and has been fixed .
关于Android-L CardView 视觉触控反馈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24475150/