如果ImageView覆盖另一个具有setBackground的ImageView,则会失去连锁效果

时间:2017-12-20 14:45:48

标签: android android-layout android-view

iv_button ImageView上的涟漪效果很好,直到我在wrapper ImageView上设置背景。如何解决这个问题?

非常感谢任何帮助。

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

    <ImageView
        android:id="@+id/wrapper"
        android:background="@color/green"  //the ripple effect works without this line
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    <ImageView
        android:id="@+id/iv_button"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_centerInParent="true"
        android:background="?selectableItemBackgroundBorderless"
        android:clickable="true"
        android:src="@android:drawable/ic_delete" />

</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

如果在该xml中设置背景,则会失去涟漪效果。如果要保留它,则应将其设置为样式,然后将该样式赋予按钮。