У меня есть два линейных выхода, каждый из которых занимает 50% от общей площади. Внутри них есть разные виды, и я не понимаю, почему horizontalScrollView1
и listView1
(посмотрите идентификаторы) не отображаются. Два вида должны расширяться, чтобы заполнить пространство, оставшееся в родительском. Что я делаю неправильно?Почему android layout_weight не работает должным образом?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent">
<HorizontalScrollView
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<HorizontalScrollView
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:id="@+id/horizontalScrollView1">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/list"/>
</HorizontalScrollView>
</LinearLayout>
<LinearLayout
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello!!!" />
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="@+id/listView1"/>
</LinearLayout>
</LinearLayout>
Вы забыли добавить тип ориентации [android: orientation = "vertical"] для обоих родительских линейных макетов, имеющих весовую сумму, для проверки уточнения ответа на готовность. –