ScrollView中嵌套ExpandableListView

为了让SrollView中嵌套ExpandableListView,咱们就得改ListView的高度,因此写一个类继承于ExpandableListview:android

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


/**
 * Created by liang on 2016/8/21.
 */
public class NestedExpandaleListView extends ExpandableListView {
    public NestedExpandaleListView(Context context,AttributeSet attrs){
        super(context,attrs);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,

                MeasureSpec.AT_MOST);

        //将从新计算的高度传递回去
        super.onMeasure(widthMeasureSpec, expandSpec);
    }
}

这样大概就能够了,之后用到的ExpandableListView就改成NestedExpandaleListView(包括xml文件,activity中用到的地方)就能够了。ide

参考资料:http://blog.csdn.net/swust_chenpeng/article/details/17413955spa

相关文章
相关标签/搜索