我有一个黄色,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>
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
编辑2
如果我将该android:clipChildren="false"属性放在父LinearLayout中,我会得到以下内容:

Kar*_*aru 70
android:clipChildren="false"允许每个孩子在父母内部绘制自己的边界之外.它不允许孩子在父母本身之外画画.为此,您需要设置android:clipChildren="false"祖父母(以及).
我认为你所看到的颜色只是因为颜色没有固有的界限.如果没有任何剪裁它们,颜色将永远消失.我的理论是,如果你使用拉伸的1x1像素图像而不是颜色,事情会有所不同.
Mor*_*goo 24
还设置
android:clipToPadding="false"
Run Code Online (Sandbox Code Playgroud)
旁:
android:clipChildren="false"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22534 次 |
| 最近记录: |