Split layout in 2 columns

Asked

Viewed 1,618 times

3

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

1 answer

2


You can use weight:

layout_weight= "1"

If the elements have the same weight, they will have 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>

Follows the documentation.

Greetings

Browser other questions tagged

You are not signed in. Login or sign up in order to post.