Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In android, how should I put 2 buttons in one row having same width and height?

Tags:

android

In android, how should I put 2 buttons in one row having same width and height? Which layout should I use?

like image 996
preety pari Avatar asked Dec 21 '22 16:12

preety pari


1 Answers

layout_weight is responsible for setting up components in equal or different proportions.

Use This :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
>
<Button android:text="@+id/Button01" android:id="@+id/Button01" 
android:layout_weight="1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="@+id/Button02" android:id="@+id/Button02" 
android:layout_weight="1"  android:layout_width="wrap_content" 
android:layout_height="wrap_content"></Button>
</LinearLayout>
like image 189
Kartik Domadiya Avatar answered May 14 '23 10:05

Kartik Domadiya