How to put two buttons on same line in Android

user1314147 picture user1314147 · Apr 17, 2012 · Viewed 51.4k times · Source

How can I place two buttons on the same line in my login layout on my Android application?

Answer

Sreedev R picture Sreedev R · Apr 17, 2012

Just make a linear layout.Set the orientation to horizontal and add two buttons.Its ready you will get what you want.Before posting such questions try googling you will get the answer for sure.This piece of code will help you.

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

</LinearLayout>

if you want to fit the two buttons in the layout.give the weight as 1 for both the buttons.