0

My View hierarchy looks like this:

<RelativeLayout>
    <ImageView
        android:id="@+id/my_background_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            androd:id="@+id/my_image"
            android:clickable="true"
            android:foreground="?attr/selectableItemBackground" />
    </LinearLayout>
</RelativeLayout>

If I set an image Drawable to my_background_image, the ripple drawable provided by ?attr/selectableItemBackground over my_image disappears. It doesn't matter what image I use, the ripple is completely gone. I've also found that the background (which includes the down arrow) of any "foreground" Spinner also disappears.

This is very strange behaviour. Does anyone know why this is happening?

Edit: I'd like to add that the ripple appears as long as src="..." is not included in the background ImageView or setImageDrawable() is not called on it.

David Heisnam
  • 2,463
  • 1
  • 21
  • 32

1 Answers1

0

Setting a transparent background to the LinearLayout solves the problem.

"Borderless buttons draw their content on the closest background. Your button might not be having background between itself and the ImageView, so it draws underneath the ImageView" from This Answer

David Heisnam
  • 2,463
  • 1
  • 21
  • 32