对子视图的连锁反应不起作用 [英] ripple effect on child views not working
本文介绍了对子视图的连锁反应不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是布局代码
<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 works only outside child views. how to achieve ripple to effect whole layout including childviews?
推荐答案
您可以尝试更改
android:background="?android:attr/selectableItemBackground"
到
android:foreground="?android:attr/selectableItemBackground"
这将使波纹出现在RelativeLayout的顶部,因此所有的ChildView也会在它们上面得到波纹.
This will make the ripple appear on top of the RelativeLayout, so all your ChildViews will also get the ripple over them.
区别是:
在顶部RelativeLayout中,背景设置为selectableItemBackground,而在底部,前景设置为selectableItemBackground
In the top RelativeLayout the background is set as selectableItemBackground, whereas in the bottom the foreground is set as selectableItemBackground
这篇关于对子视图的连锁反应不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文