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的一些屬性android:divider="@null" 表示group item之間無分割線;android:groupIndicator="@null"表示group item顯示展開或收縮的圖標消失。Android ScrollView中嵌套ExpandableListView,item不顯示的問題
在項目中,發現當需要用ScrollView嵌套ExpandableListView時,無論ExpandableListView的width設置爲match_parent還是wrap_content,其item均只顯示group的第一個,其他都不顯示,點開group第一行,裏面的child數據也不顯示。網上查閱後發現,需要重新設置ExpandableListView的高度,代碼如下:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.