user2056563
user2056563

Reputation: 640

Expandable List View - Fixed Height with scroll to children

I have followed this tutorial for usage of Expandable list view.

Here is what i am trying to achieve :

[Group 1]

[Group 2]

[Group 3] --- Fixed height

..........

.........

.........

[Group 4] - Expandable list of 3 items

[Group 5] - Expandable list of 3 items

The above whole layout should not scroll, i meant all the groups should be visible only the 3rd groups few children should be visible with scroll enabled.

Can any one help me on this ?

Upvotes: 0

Views: 1337

Answers (1)

jonte
jonte

Reputation: 46

so I guess what you mean is that you want is that when each group is clicked. That group is expanded and the rest of the groups are still visible. Meaning the children would "squeeze in" between the groups.

A first approach to this would be to add a fixed size scrollview (or listview) as the sole child of every group in the expandable listview. Though from my own experience I know that nested scrolling containers work really poorly so here is what I would do instead:

Don't use expandeable listview but instead have five views that looks just like the group rows in the expandable listview, and when a group is clicked. You add a fixed size scrollview/listview just below the row that was clicked. Do you think that could work for you?

An example of how that could work would be like the code I've shown below. Use whatever type of view/button/textview you like as group headers.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <View
        android:id="@+id/group_header1"
        android:layout_width="match_parent"
        android:layout_height="48dp"/>
    <View
        android:id="@+id/group_header2"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_below="@+id/group_header1" />
    <View
        android:id="@+id/group_header3"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_below="@+id/group_header2"/>
    <ListView
        android:id="@+id/listview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/group_header3"
        android:layout_above="@+id/group_header4"/>
    <View
        android:id="@+id/group_header4"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_above="@+id/group_header5" />
    <View
        android:id="@+id/group_header5"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:layout_alignParentBottom="true" />
</RelativeLayout>

Upvotes: 1

Related Questions