android - RecyclerView item touch to highlight -
i using recyclerview
, not able see feedback when touch on item of recyclerview
. how achieve it?
i trying show feedback user when touching row of recyclerview
. ripple effect.
i want know how achieve in specific row of recyclerview
.
this recycler view's custom row layout.
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="50dp" android:id="@+id/drawer_row" android:background="?android:attr/selectableitembackground" android:clickable="true"> <textview android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centervertical="true" android:layout_marginleft="30dp" android:layout_marginstart="30dp" android:layout_toendof="@+id/navigation_image" android:layout_torightof="@+id/navigation_image" android:textsize="17sp" /> <imageview android:id="@+id/navigation_image" android:layout_width="24dp" android:layout_height="24dp" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_centervertical="true" android:layout_marginleft="30dp" android:layout_marginstart="30dp" /> <textview android:id="@+id/horizontal_line" android:layout_width="match_parent" android:layout_height="1dp" android:layout_alignparentbottom="true" android:background="#f1f1f1" /> </relativelayout>
this layout of activity
having recyclerview
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/windowbackground"> <relativelayout android:id="@+id/nav_header_container" android:layout_width="match_parent" android:layout_height="150dp" android:layout_alignparenttop="true" android:background="@drawable/ic_drawer_header"> <imageview android:id="@+id/circle_imageview" android:layout_width="80dp" android:layout_height="80dp" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:layout_alignparenttop="true" android:background="@drawable/profile_pic" android:layout_margintop="10dp" android:layout_marginleft="10dp" /> <textview android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="john doe" android:textsize="20sp" android:textcolor="#ffffff" android:layout_below="@+id/circle_imageview" android:layout_alignleft="@+id/circle_imageview" android:layout_alignstart="@+id/circle_imageview" android:layout_margintop="5dp" /> <textview android:id="@+id/textview2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="transaction technologies" android:layout_below="@+id/textview" android:layout_alignleft="@+id/textview" android:layout_alignstart="@+id/textview" android:textcolor="#ffffff" android:layout_margintop="5dp" /> </relativelayout> <android.support.v7.widget.recyclerview android:id="@+id/drawerlist" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/nav_header_container" /> </relativelayout>
i need highlight/give feedback of row being touched user. how achieve it?
thanks in advance.
you need add android:focusable="true"
in custom row item recyclerview
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="50dp" android:id="@+id/drawer_row" android:background="?android:selectableitembackground" android:focusable="true" android:clickable="true" > </relativelayout>
Comments
Post a Comment