2

I am using ExpandableListView in my app, when I expand group and scroll to child list; group header also moved up with scroll. Any one please help me to disable group header from moving up only child list should move up.

Please help me implementing this feature.

Thanks in advance

Nuraiz
  • 1,030
  • 5
  • 17
  • 34

2 Answers2

1

I think You can't do this with ExpandableListView.

There are many other way available to make this

You should check,

StickyListHeaders : https://github.com/emilsjolander/StickyListHeaders

HeaderListView : https://github.com/applidium/HeaderListView, http://applidium.github.io/HeaderListView/

It might help you..

Ajay
  • 1,219
  • 11
  • 28
0

In addition to @Ajay's answer, you can see Cabezas' trick of using ExpandableListView in a ScrollView here

Alternatively, you can create a custom NonScrollExpandableListView class like so:

public class NonScrollExpandableListView extends ExpandableListView {
public NonScrollExpandableListView(Context context) {
    super(context);
}

public NonScrollExpandableListView(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public NonScrollExpandableListView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
}

@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
            Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
    ViewGroup.LayoutParams params = getLayoutParams();
    params.height = getMeasuredHeight();
}

}

For the full implementation, see https://stackoverflow.com/a/37605908/8771403

tfad334
  • 432
  • 5
  • 10