0

My layout is a ScrollView with some TextView and other controls and also an ExpandableListView.

What I want to do is When Expanding the ExpandableListView the controls which are below it move down and again upon collapsing, all the controls move up and only Group of Expendables become Visible.

The problem is when using wrap_content for expandView's Height the expanding of it shows nothing and just the indicator (little arrow) shows that it's expanded, and when explicitly use some numbers eg. 200dp, the lowest items of expandView not shown. (Because of using two Scrolling widget together).

Here's my simplified layout.

<ScrollView
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="HardcodedText" >
    <LinearLayout>
       //some controls
    </LinearLayout>

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

        <ExpandableListView
            android:id="@+id/lstDrugs"
            android:layout_width="match_parent"

//HERE is the point that wrap_content only shows the groups header

            android:layout_height=**"wrap_content"**
            android:layout_alignParentLeft="true"
            android:layout_alignParentTop="true"
            android:divider="@drawable/dividergradient"
            android:dividerHeight="2dp" >
        </ExpandableListView>

        <Button
            android:id="@+id/btnAddDrug"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/lstDrugs"
            android:text="Add" />
    </RelativeLayout>
</LinearLayout>

mammadalius
  • 3,263
  • 6
  • 39
  • 47
  • 1
    Can you fix your posted XML first. You have 2 immediate child elements for your scrollview. Also please explain what currently happens. It is not clear from your question. – Fraggle Jul 10 '12 at 14:16
  • I've just explained what's happening on question. This is the important part of my XML not all of it. – mammadalius Jul 10 '12 at 14:23
  • Ok, thanks that helps a bit. Please add android:fillViewport="true" to your scrollView and see if that helps. Chances are you will still have issues. ListViews and ExpandableList views will are also scrolling views so it creates problems nesting these inside a Scrollview. – Fraggle Jul 10 '12 at 14:43
  • Also try giving your ExpandableListView a layout weight=1 – Fraggle Jul 10 '12 at 19:22

1 Answers1

1

I've just found my answer in this thread.

The problem is with using List inside ScrollView. To handle it you should use a layout other than the ScrollView (eg. LinearLayout) and add other widgets as Header and Footer of the list. This would enable the scrolling of the view and also expanding of the List.

Community
  • 1
  • 1
mammadalius
  • 3,263
  • 6
  • 39
  • 47