创建不受父视图约束的触摸波纹
create touch ripples unconstrained by parent view
我在 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>
update 删除了 RelativeLayout 上的背景,这与手头的实际问题无关。行为相同。
把
android:background="?selectableItemBackground"
您的
属性
AppCompatCheckBox
,而不是边界
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">
(注意 'Borderless' 后缀)
编辑 1:
另一个想法是让父视图组覆盖它的children's clipping:android:clipChildren="false" (android:clipToPadding="false")
我在 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>
update 删除了 RelativeLayout 上的背景,这与手头的实际问题无关。行为相同。
把
android:background="?selectableItemBackground"
您的
属性AppCompatCheckBox
,而不是边界
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">
(注意 'Borderless' 后缀)
编辑 1:
另一个想法是让父视图组覆盖它的children's clipping:android:clipChildren="false" (android:clipToPadding="false")