coffee
coffee

Reputation: 3088

Is it possible to evenly distribute buttons across the width of an android RELATIVE LAYOUT

Simple Ask

Is it possible to evenly distribute buttons across the width of an android RELATIVE LAYOUT?

<RelativeLayout android:layout_height="wrap_content" android:layout_width="fill_parent"
    android:id="@+id/menu" android:layout_alignParentBottom="true">
    <Button android:layout_height="30dp" android:layout_width="wrap_content"
        android:text="aaaaaaa" android:id="@+id/aaaa"
        android:layout_alignParentLeft="true"></Button>
    <Button android:layout_height="30dp" android:layout_width="wrap_content"
        android:text="bbbbbbb" android:id="@+id/bbbbb"
        android:layout_centerHorizontal="true" android:textStyle="bold"></Button>
    <Button android:layout_height="30dp" android:layout_width="wrap_content"
        android:text="cccccccc" android:id="@+id/cccccc"
        android:layout_alignParentRight="true" android:textStyle="bold"></Button>

Upvotes: 4

Views: 3501

Answers (2)

f20k
f20k

Reputation: 3106

How about throwing a LinearLayout inside your RelativeLayout, and adding the Buttons inside the LinearLayout (all of the buttons should have the same layout_weight).

Upvotes: 6

CaseyB
CaseyB

Reputation: 25060

The only way that I know of is to put them in a LinearLayout and set the weight.

Upvotes: 2

Related Questions