我有一个黄色RelativeLayout
包含一个更高的红色LinearLayout
。
为了使整体LinearLayout
可见,我设置了android:clipChildren="false"
,但这不能按预期工作:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="44dp"
android:background="#FFFF00"
android:clipChildren="false" >
<LinearLayout
android:layout_width="50dp"
android:layout_height="100dp"
android:background="#FF0000"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
- 与
android:clipChildren="true"
:
红色LinearLayout
按预期剪裁
- 与
android:clipChildren="false"
:
其中LinearLayout
高度被剪裁,并且布局中设置的宽度不受尊重。
怎么了?
编辑
如果我将容器包装在LinearLayout
两个尺寸与其父级匹配的容器中,我会得到相同的结果(我检查了 LinearLayout 容器的容器是否填满了整个屏幕)。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="44dp"
android:background="#FFFF00"
android:clipChildren="false" >
<LinearLayout
android:layout_width="50dp"
android:layout_height="100dp"
android:background="#FF0000"
android:orientation="vertical" >
</LinearLayout>
</RelativeLayout>
</LinearLayout>
编辑 2
如果我将android:clipChildren="false"
属性放在父 LinearLayout 中,我会得到以下信息: