Skip to content Skip to sidebar Skip to footer

How To Add Two Buttons Next To Each Other? (buttons With Background Image, Not Imagebuttons)

I want two buttons next to each other like this: [ Use ] [ Cancel ] (These are just buttons with background images, NOT ImageButtons) But the result is strange, the first button

Solution 1:

add layout_weight attribute to both the buttons. set it to 1.

or maybe removing layout_weight from the linear layout works as well.

Solution 2:

Use this:

Give weight=1 for each component (or give weightsum=1 for LinearLayout & weights 0.5 to Buttons)

<LinearLayoutandroid:layout_width="fill_parent"android:orientation="horizontal"android:id="@+id/linearLayout2"android:layout_gravity="bottom"android:layout_height="fill_parent"><Buttonandroid:weight="1"android:text="Use"android:height="14dp"android:textSize="15sp"android:textColor="#ffffff"android:background="@drawable/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/UseButtonDialog"android:layout_gravity="bottom"></Button><Buttonandroid:weight="1"android:text="Cancel"android:background="@drawable/button1"android:height="14dp"android:textSize="15sp"android:textColor="#ffffff"android:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/CancelButtonDialog"android:layout_gravity="bottom"></Button></LinearLayout>

Post a Comment for "How To Add Two Buttons Next To Each Other? (buttons With Background Image, Not Imagebuttons)"