Is there a way to display only a subset of children items when the group is expanded and allow the user to scroll through the children list to access the rest of elements in Android ExpandableListView?

var shouldLimitChildrenCount:Boolean = true

override fun getChildrenCount(groupPosition: Int): Int {
    if (shouldLimitChildrenCount) {
        return 5 // show only 5 elements
    return children.size // actual size

override fun onGroupExpanded(groupPosition: Int) {
    shouldLimitChildrenCount = false

override fun onGroupCollapsed(groupPosition: Int) {
    shouldLimitChildrenCount = true

Have tried above approach but the children list doesn't scroll and always shows first 5 children items!

0 Answers