我有一个黄色的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>
- with
android:clipChildren="true"
:
与红色LinearLayout
按预期剪裁
- with
android:clipChildren="false"
:
哪里的LinearLayout
高度被剪裁,并且不遵守布局中设置的宽度。
怎么了?
EDIT
如果我将容器包裹在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>
EDIT 2
如果我把android:clipChildren="false"
父 LinearLayout 中的属性,我得到以下内容:
android:clipChildren="false"
允许每个子级在父级内部的其自身边界之外进行绘制。它不允许孩子们在父母本身之外进行绘画。为此你需要设置android:clipChildren="false"
对祖父母(以及)。
我认为你所看到的颜色只是因为颜色没有固有的界限。如果没有任何东西剪裁它们,颜色就会永远消失。我的理论是,如果您使用拉伸的 1x1 像素图像而不是颜色,情况就会有所不同。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)