我想要三個按鈕在同一行中水平放置相等數量的可用空間。 我用android:layout_gravity
。問題是什麼?在LinearLayout中放置3個按鈕以佔用相等的空間量
佈局的xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1.0"
>
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Bg"
android:background="@drawable/button_red"
android:layout_weight=".2"
android:layout_gravity="left"
/>
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/Bm"
android:background="@drawable/button_red"
android:layout_weight=".2"
android:textColor="#ffffff"
android:layout_gravity="center"
/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_red"
android:layout_weight=".2"
android:text="@string/Bf"
android:layout_gravity="right"
/>
</LinearLayout>
,如果有人看到什麼是錯,謝謝。
,並確保你給不同的ID以按鈕.. – Ronnie 2012-07-26 12:34:16