Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>

like image 716
coffee Avatar asked Feb 24 '23 19:02

coffee


2 Answers

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).

like image 162
f20k Avatar answered Feb 26 '23 07:02

f20k


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

like image 31
CaseyB Avatar answered Feb 26 '23 07:02

CaseyB