Android align two buttons

I have two buttons next to each other. I want them to be the same size and fill the entire width of the screen. I tried using this code: (This is relevant if that matters)

<Button android:text="Names" android:id="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> </Button> <Button android:text="Dates" android:id="@+id/Button02" android:layout_toRightOf="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> </Button> 
+4
source share
1 answer

Wrap LinearLayout around the buttons? then you can use the indentation to adjust the exact location if necessary

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <Button android:text="Names" android:id="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> </Button> <Button android:text="Dates" android:id="@+id/Button02" android:layout_toRightOf="@+id/Button01" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="1"> </Button> </LinearLayout> 
+25
source

Source: https://habr.com/ru/post/1338576/


All Articles