tags:

views:

91

answers:

3

Linear layout below. This layout is aligned parent bottom in a Relative Layout. Problem is I want all buttons to have the same height. I have tried layout_gravity="fill" but that doesn't seem to work.

<LinearLayout android:id="@+id/button_layout" 
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:background="#FFFFFF"
        android:layout_alignParentBottom="true">
    <Button android:text="Send" android:id="@+id/send_button"
        android:layout_weight="1" android:layout_gravity="fill"
        android:layout_width="0dip" android:layout_height="wrap_content">
    </Button>
    <Button android:text="Report Missing Image" android:id="@+id/report_button"
        android:layout_weight="1"
        android:layout_width="0dip" android:layout_height="wrap_content">
    </Button>
    <Button android:text="Close" android:id="@+id/close_button"
        android:layout_weight="1" android:layout_gravity="fill"
        android:layout_width="0dip" android:layout_height="wrap_content">
    </Button>
</LinearLayout>
+1  A: 

Try setting the layout_height on the buttons to fill_parent. This will cause them to all take up the amount of space in the parent.

Mayra
doh! had a brain fart. Any idea why fill doesn't do that? Can you combine gravities like bottom|fill?
BrennaSoft
I'm not sure...but the layout_gravity="fill" and the layout_height="wrap_content" seem to contradict each other, so android must choose to listen to the layout_height? I believe you can combine gravities like that.
Mayra
A: 

You should specify the android:layout_weightsum parameter for LinearLayout with value 3. And for Buttons, the layout_weight as 1.

You don't need to specify the gravity.

Karan
+1  A: 

For the Buttons in the same layout set the following:

android:layout_weight="1"
android:layout_height="fill_parent"

that way, the Button will have equal right to fill the parent layout's height so their heights will be the same size.

Omer