儿童观点的涟漪效应无效

时间:2017-02-09 07:10:38

标签: android android-layout

这是布局代码

    <RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
xmlns:android="http://schemas.android.com/apk/res/android" >
<TextView
    android:id="@+id/save"
    android:layout_centerVertical="true"
    android:text="@string/save"
    android:textSize="@dimen/text_size"
    android:textColor="@color/white"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
<ImageView
    android:layout_toRightOf="@+id/save"
    android:layout_centerVertical="true"
    android:src="@drawable/ic_right_arrow"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" /></RelativeLayout>

涟漪仅在儿童视野之外起作用。如何实现涟漪影响整个布局,包括儿童视图?

1 个答案:

答案 0 :(得分:6)

您可以尝试更改

android:background="?android:attr/selectableItemBackground"

android:foreground="?android:attr/selectableItemBackground"

这会使纹波出现在RelativeLayout的顶部,因此所有的ChildViews也会在它们之间产生涟漪。

区别在于:

Click on two RelativeLayouts

在顶部RelativeLayout中,背景设置为selectableItemBackground,而在底部,前景设置为selectableItemBackground