我想设置我的所有孩子在我的Linerlayout中,以在显示最长的孩子视图所需的最大宽度上具有相等的宽度基础。
使您将warap_content和所有子元素的宽度作为match_parent。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="small text"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="some long text test" />
</LinearLayout>
</LinearLayout>
设置父linearlayout的宽度,并将其所有儿童设置为 match_parent
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="small text"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="some long text test" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
</LinearLayout>