我无法对齐LinearLayout。尝试不同的方式,但仍然歪。 我需要:
全屏
所有部分都是平等的。但实际上我有一个非常小的最后一部分
<?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>
编辑:改变了建议,但也没有提供所需的重新填充
<?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>
答案 0 :(得分:1)
当您使用水平layout_weight
进行演奏时:
android:layout_width="0dp"
如果您希望所有这些内容相同,请删除margins
并改为使用padding
。