Android レイアウト 水平方向、均等な配置

Android のレイアウト、ボタンなどを均等に並べる場合
ポイントは、layout_width match_parent に、
各部品の layout_weight を 1 にする。

例)

<LinearLayout
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >
    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button" />
    <Button
        android:id="@+id/button2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="Button" />
</LinearLayout>

f:id:posturan:20160314233723j:plain