Android Layout Division

I want to split my screen into two parts, I have one LinearLayout, and it contains two LinearLayoutsagain.

How to divide these two LinearLayoutsinto two equal parts?

+3
source share
4 answers

Just add:

android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"

for both of them. An layout_weightequal parameter evenly distributes the amount of space.

Work on accepting some answers to your previous questions.

+8
source

I usually use android: layout_weight = "1" for this. You can also use a table layout.

+1
source

, .

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    android:id="@+id/rootlinearlayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    xmlns:android="http://schemas.android.com/apk/res/android">
    <LinearLayout
        android:id="@+id/linearlayout01"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:orientation="vertical">
        <EditText
            android:id="@+id/et01"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="First TextBox"
            android:textSize="18sp" />
    </LinearLayout>
    <LinearLayout
        android:id="@+id/linearlayout02"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:orientation="vertical">
        <EditText
            android:id="@+id/et02"
            android:gravity="center"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Another TextBox"
            android:textSize="18sp" />
    </LinearLayout>
</LinearLayout>
0

android:layout_width="0dp" android:layout_weight="1" android:layout_width="fill_parent"

0

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


All Articles