ScrollView中嵌套ExpandableListView


為了讓SrollView中嵌套ExpandableListView,我們就得改ListView的高度,所以寫一個類繼承於ExpandableListview:

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中用到的地方)就可以了。

參考資料:http://blog.csdn.net/swust_chenpeng/article/details/17413955


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM