androidlistviewandroid-scrollviewxml-layout

ListView inside ScrollView in android


I'm having the listview inside the scrollview when I'm running the app list is scrolling limited to the first item. I think the Scrillview is overriding scrolling of listview here is my code:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.7"
    android:padding="10dp">

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

            <Button
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:id="@+id/client_detail"
                android:text="CLIENT INFORMATION"
                android:textColor="@color/colorPrimaryDark"
                android:background="@drawable/login_selector"/>

                <RelativeLayout
                    android:id="@+id/rl1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:padding="10dp"
                    android:visibility="gone"
                    android:layout_below="@+id/client_detail">

                    /* HERE IS MY SOME OTHER LAYOUT */

                </RelativeLayout>
                <Button
                    android:text="CONTACT DETAILS"
                    android:layout_width="match_parent"
                    android:layout_height="40dp"
                    android:background="@drawable/login_selector"
                    android:textColor="@color/colorPrimaryDark"
                    android:layout_below="@+id/rl1"
                    android:layout_marginTop="10dp"
                    android:layout_centerHorizontal="true"
                    android:id="@+id/contactDetails" />

                <ListView
                    android:id="@+id/listView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/contactDetails"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="10dp" />

        </RelativeLayout>
    </ScrollView>    
</RelativeLayout>

Please need some help, thanks in advance!


Solution

  • You need to use ExpandableHeightListView.

    https://github.com/paolorotolo/ExpandableHeightListView