1

I have RecyclerView with list of data:

<android.support.v7.widget.RecyclerView
        android:id="@+id/categoriesList"
        android:layout_width="368dp"
        android:layout_height="0dp"
        android:layout_marginBottom="8dp"
        android:layout_marginEnd="8dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:clickable="true"
        android:focusable="true"
        android:foreground="?android:attr/selectableItemBackground"
        android:background="?android:selectableItemBackground"/>

When I tap to any items in this list, I wait pressing effect. I do not have a click handler, but in the standard ListView, any click on an element is visible. And I look like there's nothing to react

I need next:

enter image description here

ip696
  • 6,574
  • 12
  • 65
  • 128

2 Answers2

2

You need to add these lines to your single row layout instead of recyclerview tag.

android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:background="?android:selectableItemBackground"
kunwar97
  • 775
  • 6
  • 14
0

This is your answer: How can I give an imageview click effect like a button on Android?

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true"   
        android:drawable="@drawable/img_down" />
    <item android:state_selected="false"   
        android:drawable="@drawable/img_up" />
</selector>

You can customized it and use it as per your choice of colour.

Sara Tirmizi
  • 417
  • 4
  • 10