我在 RelativeLayout
中有一个 android.support.v7.widget.AppCompatCheckBox
。我得到了触摸波纹,但它们受到相对布局的限制。有没有一种简单的方法可以让涟漪溢出父级? (这是使用appcompat 22.1.1)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:visibility="invisible"/>
<android.support.v7.widget.AppCompatTextView
android:id="@+id/label"
android:layout_toRightOf="@id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Checkbox"/>
</RelativeLayout>
更新删除了RelativeLayout上的背景,它与当前的实际问题无关。行为是相同的。
最佳答案
你可以试试这个:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackgroundBorderless">
(注意“无边界”后缀)
编辑1:
另一个想法是允许父 View 组覆盖其 children's clipping : android:clipChildren="false"(android:clipToPadding="false")
关于android - 创建不受父 View 约束的触摸波纹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30626019/