ExpandableListView inside a NestedScrollView won’t scroll? Use a Non-scrolling ExpandableListView

Using an ExpandableListView inside a NestedScrollView makes it unscrollable, because of the NestedScrollView scrolling interference. To solve this, you can create a non-scrolling ExpandableListView with size equal to its content.

Create this class

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.ExpandableListView;

public class NoScrollExListView extends ExpandableListView {

    public NoScrollExListView(Context context) {
    public NoScrollExListView(Context context, AttributeSet attrs) {
        super(context, attrs);
    public NoScrollExListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    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();

And instead of ExpandableListView, use NoScrollExListView.



Also published on Medium.

By |2019-04-05T09:41:26+00:00March 14th, 2019|Categories: Android Tips|4 Comments


  1. standard oyster company July 7, 2019 at 3:07 am - Reply

    Everything is very open with a very clear
    explanation of the issues. It was truly informative.
    Your website is very useful. Thank you for sharing!

  2. Mohamed December 10, 2019 at 6:49 am - Reply

    thanks in advance solve my problem

  3. master 3 mobile legend January 8, 2020 at 11:00 pm - Reply

    Hey very interesting blog!

  4. A visitor January 24, 2020 at 4:13 pm - Reply


Leave A Comment