I would like my ExpandableListView
to automatically scroll when the user expands a group, so that the expanded group header is at the top of the screen. I've tried smoothScrollToPosition
, but this merely ensures the expanded group is visible somewhere on the screen. I would like to explicitly scroll it so the expanded group is at the top, like in this example:
Before expanding Group 3: After expanding Group 3:
+=================+ +=================+
| Group 1 | | Group 3 |
+-----------------+ +-----------------+
| Group 2 | | Grp 3 Child 1 |
+-----------------+ +-----------------+
| Group 3 | | Grp 3 Child 2 |
+-----------------+ +-----------------+
| Group 4 | | Group 4 |
+=================+ +=================+
The following code is a solution that worked for me
this will scroll to the selected item, call this when u click on the group item.
Setting
android:transcriptMode="disabled"
to myExpandibleListView
worked for me too. With the parameter set to "normal", no one method works (setSelectedGroup
,setSelectionFromTop
, etc).Only
setSmoothScroll
works, but don't like the effect.setSelectedGroup
works, but if you want to have a smooth scrolling effect, usesmoothScrollToPositionFromTop
as given below:This worked for me. Put it in your adapter:
The below code works for me.Hope it will helps.Implements the OnGroupExpandListener within onGroupExpand use the below code
}