Valera Valerianov
Valera Valerianov

Reputation: 247

I can not align Layout

I can not align LinearLayout. trying different ways but still crooked. i need to:

|date|name|summ|

full screen

that all parts are equal. but in fact I have the last part of a very small

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Дата"
        android:id="@+id/order_date"
        android:textColor="#000"
        android:layout_marginLeft="5dp"
        android:background="#ffff343c"
        android:layout_weight="1" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="ФИО"
        android:id="@+id/order_fio"
        android:textColor="#000"
        android:background="#ff46ff22"
        android:layout_weight="1" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Сумма"
        android:id="@+id/order_summ"
        android:textColor="#000"
        android:layout_weight="1" />

</LinearLayout>

EDIT:changed on the advice and it also does not give the desired rezulate

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal" android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Дата"
        android:id="@+id/order_date"
        android:textColor="#000"
        android:background="#ffff343c"
        android:layout_weight="1" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="ФИО"
        android:id="@+id/order_fio"
        android:textColor="#000"
        android:background="#ff46ff22"
        android:layout_weight="1" />

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:text="Сумма"
        android:id="@+id/order_summ"
        android:textColor="#000"
        android:layout_weight="1" />

</LinearLayout>

Upvotes: 0

Views: 52

Answers (1)

Arash GM
Arash GM

Reputation: 10395

when you are using horizontal layout_weight for perfomance use :

android:layout_width="0dp"

and also if you want all of them equal remove margins and use padding instead.

Upvotes: 1

Related Questions