XML : Android Studio how to make a 2 column LinearLayout

I'm very new to Android App Development, and am trying to achieve the following button layout in Android Studio.

[App design[1]

Ive been trying to use a Linear Layout, but I couldn't get it right.

  <LinearLayout      android:orientation="horizontal"      android:layout_width="match_parent"      android:layout_height="match_parent"      android:layout_alignParentTop="true"      android:layout_alignParentLeft="true"      android:layout_alignParentStart="true"      android:layout_alignParentRight="true"      android:layout_alignParentEnd="true"      android:weightSum="1">        <Button          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:text="New Button"          android:id="@+id/button"          android:layout_alignParentBottom="true"          android:layout_alignParentRight="true"          android:layout_alignParentEnd="true"          android:background="#016eff"          android:layout_alignParentLeft="true"          android:layout_alignParentStart="true"          android:layout_margin="10dp"          android:textColor="#ffffff"          android:layout_weight="0.48" />        <Button          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:text="New Button"          android:id="@+id/button2"          android:layout_alignParentBottom="true"          android:layout_alignParentRight="true"          android:layout_alignParentEnd="true"          android:background="#016eff"          android:layout_alignParentLeft="true"          android:layout_alignParentStart="true"          android:layout_margin="10dp"          android:textColor="#ffffff"          android:layout_weight="0.48" />  </LinearLayout>    

The problem with this is, if I added another button to the Linear Layout, then they just get squished together, instead of adding the button to the next row.

Can someone please show me to make my LinearLayout only have 2 widgets on each row.

Any help will be much appreciated thanks :-)

No comments:

Post a Comment