Search code examples
androidandroid-layoutandroid-linearlayout

Android linear layout not matching its parent


I am creating a listview inside a scroll view, i want the listview to match its parent. the Scroll view is matching its parent and acquiring complete screen. but the linear layout inside it is not matching its parent and acquirig the whole screen, so as the list view

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >


<LinearLayout
    android:id="@+id/linearlayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

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

            </ListView>
</LinearLayout>
    </ScrollView>




</LinearLayout>

Solution

  • Yes, as njzk2 said, you can't do that. I had issues with ListViews in a scrollview

    I don't use ListViews. I just use Buttons in general. They work much better.