Highlight selected line in Recyclerview

Asked

Viewed 140 times

1

How to highlight the selected line (clicked) in recyclerview? Listview was automatic. Thanks in advance.

1 answer

0


Hello!

I’ll assume you’re talking about the effect rippe, which is the effect of the image below:

Imagem com efeito rippe

Just put the attributes below in the inflated parent layout by your Adapter.

android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground"

Example:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    android:clickable="true"
    android:focusable="true"
    android:background="?attr/selectableItemBackground">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.