android - Adding Ripple Effect to RecyclerView item -


this question has answer here:

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: enter image description here

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: enter image description here


Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -