could anybody explain to me how to implement some of the visual touch feedback that was demonstrated at Google I/O 2014 within a CardView.
Here is how I am using the CardView in XML, there is probably something small that I am missing, so I just wondered if anyone could help me?.
<!-- 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+:
Add android:foreground="?android:attr/selectableItemBackground"
to your CardView
element.
API 9+:
Add android:foreground="?selectableItemBackground"
to your CardView
element.
Edit: The ripple originating from the center and not from the touch point is a known bug, and has been fixed.