android - Adding Ripple Effect to RecyclerView item -
this question has answer here:
- touch feedback recyclerview , cardview 9 answers
i trying add ripple effect recyclerview's item. had online, not find need. assume has custom effect. have tried android:background attribute recyclerview , set "?android:selectableitembackground" did not work.:
<android.support.v7.widget.recyclerview android:layout_width="match_parent" android:layout_height="match_parent" android:focusable="true" android:clickable="true" android:background="?android:selectableitembackground" android:id="@+id/recyclerview" android:layout_below="@+id/tool_bar"/> this recyclerview trying add effect to: 
i figured out. thing had add attribute:
android:background="?android:attr/selectableitembackground" to root element of layout recyclerview adapter inflates that:
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingtop="8dp" android:paddingbottom="8dp" android:background="?android:attr/selectableitembackground" tools:background="@drawable/bg_gradient"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="17sp" android:layout_marginleft="15dp" android:layout_marginstart="15dp" android:id="@+id/shoppinglistitem" android:hint="@string/enter_item_hint" android:layout_centervertical="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true"/> <checkbox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/shopping_list_item_checkbox_label" android:id="@+id/shoppinglistcheckbox" android:layout_centervertical="true" android:layout_marginright="15dp" android:layout_alignparentright="true" android:layout_alignparentend="true" android:checked="false"/> </relativelayout> result: 
Comments
Post a Comment