天天看點

android:layout_width="0.0dip",使視圖寬度wrap_content,但不超過0.5重量

在我的LinearLayout中,我有兩個子ViewGroups,基本上我希望他們每個占用50%的空間(并完成),但也有可能是内容其中一個ViewGroups遠小于50%,在這種情況下,有什麼辦法讓第二個視圖比對剩餘的空間?使視圖寬度wrap_content,但不超過0.5重量

現在我的布局是這樣的:

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:paddingTop="5dp"

android:paddingBottom="5dp"

android:orientation="horizontal"

android:weightSum="1">

android:layout_width="0dip"

android:layout_weight="0.5"

android:layout_height="match_parent" />

android:layout_width="0dip"

android:layout_weight="0.5"

android:layout_height="match_parent" />

而我要實作的是:一個布局WRAP_CONTENT,但不超過50%,而第二布局填充剩餘空間。

在此先感謝!

2012-12-01

gysyky