ScrollView with LinearLayout child does not wrap_content correctly

Costin :

So, I have the following .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>

The issue is that the last ListView is on only 1 row, and it has to be scrolled to display all the items in the list. I tried to add to the linear_parent a height of match_parent but it wont let me, it says that I should use instead wrapcontent. How can i change the layout to display the items on all the screen, not just half?enter image description here

Murat Çakır :

In this case, On the ScrollView use android:fillViewport="true" and for child of ScrollView android:height="wrap_content".

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=175000&siteId=1