5

I have created a list item (as shown in the picture) with an ImageView (The beautiful Miranda Kerr) and an ImageButton (The trash icon) with background selectableItemBackgroundBorderless.

enter image description here

Now, when I click on the trash icon, the ripple is created behind the ImageView

Naturally, I want the ripple to take place in front of the image and behind the trash icon.

Full item.xml:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/image_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        tools:src="@drawable/cover"
        />

    <ImageButton
        android:id="@+id/trash_image_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right|bottom"
        android:src="@drawable/translucent_trash"
        android:background="?attr/selectableItemBackgroundBorderless"
        />
</FrameLayout>
Vedant Agarwala
  • 18,146
  • 4
  • 66
  • 89

1 Answers1

1

This is the same problem in : Ripple behind other view

You can wrapp your button by a FrameLayout with a background transparent.

Community
  • 1
  • 1
Trung Nguyen
  • 21
  • 1
  • 2