ScrollView с дочерним элементом LinearLayout неправильно wrap_content - PullRequest
1 голос
/ 06 марта 2020

Итак, у меня есть следующее. xml:

    <?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.scopesystems.cityalert.ui.Despre"
    tools:showIn="@layout/app_bar_despre"
    android:background="@drawable/toolbar_incercare">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:id="@+id/linear_parent">
        <RelativeLayout
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="0.1" />
        <RelativeLayout
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="2.8" >
            <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <!--General-->
        <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        style="@style/sectionHeader"
        android:text="@string/general"
        />
        <ListView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/despre_general"/>
        <!--Evaluti-ne-->
        <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        style="@style/sectionHeader"
        android:text="@string/evaluatine"
        />
        <!--Confidentialitate si licente-->
        <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        style="@style/sectionHeader"
        android:text="@string/confidentialitate"
        />
        <ListView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/despre_politici"/>
    </LinearLayout>
        </RelativeLayout>
        <RelativeLayout
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_weight="0.1" />
    </LinearLayout>
</ScrollView>

Проблема в том, что последний ListView находится только в 1 строке, и его необходимо прокручивать, чтобы отобразить все элементы в список. Я пытался добавить к linear_parent высоту match_parent, но он не позволил мне, он говорит, что я должен использовать вместо wrapcontent. Как я могу изменить макет для отображения элементов на всем экране, а не только на половине? enter image description here

1 Ответ

1 голос
/ 09 марта 2020

В этом случае на ScrollView используйте android:fillViewport="true", а для дочернего ScrollView android:height="wrap_content".

...