views:

63

answers:

1

I have two ImageButtons, and I am trying to stack one on top of the other. I essentially want to make a screen with two big buttons that each take up 50% of the available space. The code is below. Here is a capture of the layout it yields http://imgur.com/cQT0W.png I have played around with layout_gravity and gravity on the parent. Setting both chidren with layout_height=fill_parent doesn't work nor does setting the parent's gravity to fill_vertical.

        <!-- Notes tab -->
        <LinearLayout android:id="@+id/tabNotes"  
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"             
            android:padding="6dp"
            android:orientation="vertical">                                                 
            <ImageButton android:src="@drawable/ic_btn_speak_now" android:id="@+id/imgSpeakNow"                         
                android:background="#FFFF00"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                />                  
            <ImageButton android:src="@drawable/ic_btn_compose" android:id="@+id/imgCompose" 
                android:background="#FF00FF"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"                                    
                />
        </LinearLayout>
+1  A: 

Use android:layout_weight; set both buttons to have the same value.

Using RelativeLayout instead of LinearLayout may help, too.

Carl Manaster
You rock man. Thanks a lot.