我有一個黃色RelativeLayout
包含一個較高的紅色LinearLayout
。無法獲得clipChildren = false屬性
爲了使整個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>
EDIT 2
如果我把父的LinearLayout的android:clipChildren="false"
屬性,我得到如下:
相對佈局具有機器人:layout_height = 「44dp」。它本身就是由它的父親 – njzk2
加密的,我用setContentView(R.layout.test);直接設置了這個佈局。沒有明確的父母。根視圖組是否填滿整個屏幕?爲什麼要修改LinearLayout的寬度? – jul
@ njzk2:爲了做更多的測試,我嘗試了不同的佈局,並且它仍然不起作用(請參閱我的編輯) – jul