0

I have a basic layout here, but the LinearLayout inside ScrollView is not matching the parent height.

<LinearLayout
    .
    .
    android:layout_width = "match_parent"
    android:layout_height = "match_parent"
    android:orientation = "vertical"
    .
    .>
    <EditText
    .
    ./>

    <Button
    .
    ./>

    <ScrollView
        android:layout_width = "match_parent"
        android:layout_height = "match_parent">

        <LinearLayout
            android:id = "@+id/layoutWeb"
            android:layout_width = "match_parent"
            android:layout_height = "match_parent"
            android:orientation = "vertical">

            <ListView
                android:id = "@+id/listWeb"
                android:layout_width = "match_parent"
                android:layout_height = "match_parent">

            </ListView>

        </LinearLayout>

    </ScrollView>

</LinearLayout>

The ide suggests to change the linear layout's(id=layoutWeb) height to wrap_parent. I have selected the linear layout in the screenshot below, but its height is not matching the parent Screenshot

Eyad Kobatte
  • 58
  • 2
  • 12
  • 1
    Never put ListView inside ScrollView, and does the first LinearLayout containe any padding ? – Abdennacer Lachiheb Feb 10 '17 at 10:45
  • I just realized that was so stupid. But why wouldn't it work? – Eyad Kobatte Feb 10 '17 at 10:46
  • match_parent does not work in ScrollView root. Also you should newer put one scroll into another (ListView into ScrollView). – Vladyslav Matviienko Feb 10 '17 at 10:46
  • ListView inside ScrollView not match with parent layout height for that either you can use recycler view or refer this link http://stackoverflow.com/questions/21264951/problems-with-gridview-inside-scrollview-in-android – Akash Feb 10 '17 at 10:47

1 Answers1

4
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<LinearLayout
    android:id="@+id/layoutWeb"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <ListView
            android:id="@+id/listWeb"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
</LinearLayout>

try this code . for listview you dont need to take scrollview. its already scrollable

PRATEEK BHARDWAJ
  • 2,364
  • 2
  • 21
  • 35