Android 子视图的连锁反应不起作用
这是布局代码Android 子视图的连锁反应不起作用,android,android-layout,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
<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>
ripple仅在子视图之外工作。如何实现ripple以影响包括子视图在内的整个布局?您可以尝试更改
android:background="?android:attr/selectableItemBackground"
到
这将使涟漪出现在RelativeLayout的顶部,因此您的所有子视图也将在其上产生涟漪
区别在于:
在顶部的RelativeLayout中,背景设置为selectableItemBackground,而在底部,前景设置为selectableItemBackgroundset“android:background=“?android:attr/selectableItemBackground”。因此,您希望子视图在单击时具有各自的涟漪,当点击任何东西时,相对论是否会产生涟漪?@Rachit否我只希望在整个布局中出现一个涟漪,因此只需设置android:background=“?android:attr/selectableItemBackground”即可。什么对您不起作用?谢谢,android:前台=“?android:attr/selectableItemBackground”在整个布局中只起一个涟漪
android:foreground="?android:attr/selectableItemBackground"