<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:orientation="vertical" >
<Button
android:layout_width="fill_parent"
android:layout_weight="1" />
<Button
android:layout_width="fill_parent"
android:layout_weight="1" />
<Button
android:layout_width="fill_parent"
android:layout_weight="1"
android:visibility="gone" />
</LinearLayout>
現在,如果您設置可見的第三個按鈕,其他兩個buttos將調整大小以顯示屏幕上的3個按鈕。水平佈局中的相同視圖:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white"
android:orientation="horizontal" >
<Button
android:layout_height="fill_parent"
android:layout_weight="1" />
<Button
android:layout_height="fill_parent"
android:layout_weight="1" />
<Button
android:layout_height="fill_parent"
android:layout_weight="1"
android:visibility="gone" />
</LinearLayout>
非常感謝!我正在尋找這樣的解決方案:) –