【问题标题】:ImageView lose ripple effect if it overlays another ImageView having setBackground如果 ImageView 覆盖另一个具有 setBackground 的 ImageView,它会失去涟漪效应
【发布时间】:2017-12-20 22:53:35
【问题描述】:

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>

【问题讨论】:

标签: android android-layout android-view


【解决方案1】:

如果您在该 xml 中设置背景,您将失去涟漪效果。如果你想保留它,你应该将它设置为一个样式,然后将该样式赋予你的按钮。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-02
    • 1970-01-01
    • 2016-11-14
    • 2015-03-04
    • 2015-02-11
    • 2016-04-25
    • 1970-01-01
    相关资源
    最近更新 更多