if you know the sizes of your buttons before, then you can put Layouts into Layouts. See this example that represents your image:
<LinearLayout
android:id="@+id/outerLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:id="@+id/innerLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:id="@+id/button1"
android:layout_width="0dp"
android:layout_weight="5"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_weight="5"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/innerLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:id="@+id/button3"
android:layout_width="0dp"
android:layout_weight="5"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/button4"
android:layout_width="0dp"
android:layout_weight="5"
android:layout_height="wrap_content"
/>
</LinearLayout>
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_weight="5"
android:layout_height="wrap_content"
/>
</LinearLayout>
As you can see, with the layout_weight
attribute you can manipulate the width of a button. This is possible too by setting a concrete size in layout_width
except match_parent
.
The same thing if you add View
s from Code. However I prefer explaining Android layouts in XML, as you got a way better overview.