这类问题简单来说就是一个高度测量的问题,由于ScrollView的引入,无法正确的测量出ListView的高度,导致显示不完全甚至不显示的问题。重写ListView的onMeasure方法可处理。
public class CustListView extends ListView {
public CustListView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public CustListView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
public CustListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}