У меня есть небольшой linearlayout с другим linearlayout, который имеет некоторые ошибки, когда я добавляю к нему весы и стараюсь, чтобы он занял весь экран. Пожалуйста, проверьте мой код и помогите мне.Элементы линейной компоновки, не занимающие весь экран
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/linear_layout_two"
android:layout_below="@+id/linear_layout_one"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="60dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="25dp"
android:textColor="#3193b9"
android:text="99.3%"
android:layout_weight="1"
android:id="@+id/goals_accuracy"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="10dp"
android:gravity="center"
android:text="Goals accuracy"
android:layout_weight="1"
android:id="@+id/goals_accuracy_2"/>
</LinearLayout>
<ImageView
android:layout_width="0dp"
android:layout_height="60dp"
android:src="@drawable/the_vertical"
android:id="@+id/imageView8" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="60dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="25dp"
android:textColor="#3193b9"
android:text="10:30hr"
android:gravity="center"
android:layout_weight="1"
android:id="@+id/total_time_on_ice"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="10dp"
android:text="Total time on ice"
android:gravity="center"
android:layout_weight="1"
android:id="@+id/total_time_on_ice_2"/>
</LinearLayout>
</LinearLayout>
Я пробовал добавлять к нему весы, но он не работал, поэтому я удалил его. Хотя я знаю, что мне нужно установить ширину в 0 и установить вес в 1, но я смущен тем, как заставить ее работать с вложенными макетами. Тем не менее, я был в состоянии сделать работу на одном LinearLayout ...
Ваша проблема в том, что ваш 2 sub linearlayout не принимает всю родительскую ширину? – firegloves
Yup, все вещи внутри каждого макета, чтобы заполнить всю ширину экрана одинаково, изображение между этими двумя макетами - это просто изображение вертикальной линии. –