Split layout into 2 columns

3

I have my home screen code that needs to be split into two equal parts. How do I split a linear layout into two columns of equal size?

    
asked by anonymous 23.11.2015 / 17:44

1 answer

2

You can use weight:

layout_weight= "1"

If the elements have the same weight, they will be the same size.

Example:

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_centerHorizontal="true">

    <EditText
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />
</LinearLayout>

Follow documentation .

Greetings

    
23.11.2015 / 17:50