Highlight item in RecyclerView while Pressed

In the root layout of your recycler view item.xml, you can write android:foreground="?attr/selectableItemBackground". This will highlight recycler view item, when a click occurs.

For example, let`s say it is your recycler view item layout:

 <androidx.constraintlayout.widget.ConstraintLayout

    android:id="@+id/item"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:foreground="?attr/selectableItemBackground">

     ...

</androidx.constraintlayout.widget.ConstraintLayout>`

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top