1

I have 2 textviews and 1 expandable list view wrapped inside a relative layout and this layout is inside the scrollview. The expandable list view is at the bottom of the activity. I can get the activity to scroll when I have a long text for the textview but when I expand the list, it doesn't scroll down to the expanded content. Here is my XML layout and the screen shot of the activity:

<Scrollview xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context=".AboutActivity$PlaceholderFragment"
    android:id="@id/scrollview"
    android:background="#2d89ef"
    android:fillViewport="true">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@id/relativelayout"
    android:weightSum="3">
    <TextView
        android:text="ABOUT PAGE"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:textColor="#FFFFFF"
        android:id="@id/about_text"
        android:autoText="false"
        android:textStyle="normal"
        android:typeface="normal"
        android:layout_weight="1"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="@string/faq"
        android:id="@+id/textView"
        android:layout_below="@id/about_text"
        android:layout_alignParentLeft="true"
        android:layout_weight="1"/>

    <ExpandableListView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/expandableListView"
        android:layout_below="@+id/textView"
        android:layout_alignParentLeft="true"
        android:layout_weight="1"
        android:layout_alignParentBottom="true" />
</RelativeLayout>
</Scrollview>

Activity

When I expand the list, I cannot scroll to the end of the expandlistview. I want the expandlistview's height to update to wrap to its expanded content.

dgzz
  • 2,929
  • 6
  • 34
  • 56
  • 1
    possible duplicate of [Listview inside ScrollView is not scrolling on Android](http://stackoverflow.com/questions/6210895/listview-inside-scrollview-is-not-scrolling-on-android) – SimonSays Nov 13 '13 at 19:19
  • the problem of the thread above is that its internal scroll is not working. Mine is different, I don't want the internal scrolling instead, the expandablelistview and the activity's height should expand when its content is expanded not activating the internal scrolling.. – dgzz Nov 13 '13 at 22:24
  • found a similar problem but it's for listView and I can't get it to work on a ExpandableListView : http://stackoverflow.com/questions/3495890/how-can-i-put-a-listview-into-a-scrollview-without-it-collapsing – dgzz Nov 13 '13 at 22:36
  • im confused what to replace to the list.getCount() because my ExpandableListAdapter has getChildCount() and getGroupCount() what should I use? – dgzz Nov 13 '13 at 22:53
  • 1. The basic answer is always the same if you want to place a listview inside of a screollview: DON"T DO IT. 2. Look at the documentation of ExpandableListAdapter. You'll see that getChildCount() takes a group id as parameter. So first level nodes are groups, second level are children. You want to add one more group with no children at the top of your list. – SimonSays Nov 13 '13 at 23:48
  • If I will do that, can I use a separate properties for that? I want it to look like a textview but the other groups will have a white background. – dgzz Nov 13 '13 at 23:58
  • You have to be careful with that, because the Views are getting recycled. If you have only one View on top of the list, you actually better set it as list header. Look at `ExpandableListView. addHeaderView()`. – SimonSays Nov 14 '13 at 00:12
  • Ill try to do that when I get home – dgzz Nov 14 '13 at 00:45
  • Hey I have the exact same problem did you ever get a solution for this? – Dan Feb 05 '14 at 04:02
  • The ExpandableListView. addHeaderView() was the proper solution for me in the end. – Dan Feb 05 '14 at 15:06

1 Answers1

0

You should change your XML to remove the ScrollView and only use ListView. If you want your TextViews to scroll off the screen you can add them as the first Rows to the listview.

mtbomb
  • 1,107
  • 1
  • 13
  • 16