0

I have a dynamic space between listView and ExpandListView. The idea is to expand the expand list view in the space first, and when the space consumed use the scrollView to show the parts off the screen. The problem is scrollView is not scrolling at all:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="250dp"
    android:layout_height="match_parent"
    android:id="@+id/menu_navigation"
    android:background="@drawable/gradient"
    tools:context=".NavigationDrawerFragment">

    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ListView
                android:id="@+id/navigationTopList"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:choiceMode="singleChoice"
                android:divider="@android:color/transparent"
                android:dividerHeight="0dp"
                android:isScrollContainer="false"/>
// dynamic space
            <View android:layout_width="wrap_content"
                android:layout_height="0dp"
                android:layout_weight="1"/>
//should show on the bottom and expand in the dynamic space and if exceed should be scrolled through scrollView
            <ExpandableListView
                android:id="@+id/navigationBottomList"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:groupIndicator="@null"/>
        </LinearLayout>
    </ScrollView>

</LinearLayout>
Kohlbrr
  • 3,861
  • 1
  • 21
  • 24

1 Answers1

0

According to Android, you should never include ListViews inside ScrollView. There are some workarounds here in stackoverflow:

[1] How can I put a ListView into a ScrollView without it collapsing?

[2] Android list view inside a scroll view

based on the measure of the listview children to avoid the scroll of the listview. Take a look at the several solutions.

Community
  • 1
  • 1
Luciano Rodríguez
  • 2,239
  • 3
  • 19
  • 32
  • thank you for your answer, the lists expands normally with no issues but the issue is the scrollView is not scrolling when i can see items are off the screen boundaries. so i need to fix the scrollView only not the problem with the list not scrolling or expanding – user3926970 Nov 04 '14 at 18:46
  • the problem is that Android doesn't allow two Views with scroll one inside another. To fix this behavior, people usually measures programmatically the height of the listview (the sum of the height of all of its children) and set its height to this value. This way ListView won't have scroll and only your ScrollView will scroll without any problems. Take a look at the links. – Luciano Rodríguez Nov 04 '14 at 18:50