Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android SelectableItemBackground not working

XML Layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:minHeight="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackground"
android:gravity="start|center_vertical"
android:orientation="horizontal"
android:paddingEnd="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingStart="16dp">

<ImageView
    android:id="@+id/icon"
    android:layout_width="24dp"
    android:layout_height="24dp"
    android:layout_marginEnd="32dp"
    android:layout_marginRight="32dp" />


<RobotoTextView
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="start|center_vertical"
    android:gravity="start|center_vertical"
    android:textSize="14sp"
    app:typeface="roboto_medium"
    android:textColor="@color/primary_text"/>

This is the layout for my rows in a recyclerview, I have used "?attr/selectableItemBackground" before and it worked great, but nothing is making this ripple effect work! Does anybody have any suggestions?

like image 763
Nick H Avatar asked Apr 14 '26 02:04

Nick H


1 Answers

Turns out, the selectableItemBackground was working all along, it was hidden with a combination of a white backgrounnd and the ThemeOverlay.AppCompat, i put the Light theme to each row and the ripple was then visible.

like image 127
Nick H Avatar answered Apr 16 '26 12:04

Nick H



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!