0
如何在水平LinearLayout中製作4個固定大小的按鈕來水平填充該圖層的空間,讓Android在這些按鈕之間填充所需的空間以填充那個空間?Android - LinearLayout:如何添加自動空間beetween項目以水平填充佈局
如何在水平LinearLayout中製作4個固定大小的按鈕來水平填充該圖層的空間,讓Android在這些按鈕之間填充所需的空間以填充那個空間?Android - LinearLayout:如何添加自動空間beetween項目以水平填充佈局
你在尋找類似的東西嗎?
<?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="#FFF"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:orientation="vertical" >
</LinearLayout>
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
如果我理解正確,您希望使這4個按鈕在水平LinearLayout中佔用相等的空間,如果是這樣,則在XML佈局中爲每個4個按鈕添加:android:layout_weight="1"
。
不,這使得按鍵更大。我希望這些按鈕之間的空間適應和發展,以填補空間。我想讓按鈕之間的空間充當填充物。 – Oliver