listview重新计算高度

时间:2023-01-09 09:56:51
将xml中的ListView改用下面的ListViewForScrollView


//ScrollView中嵌入ListView,让ListView全显示出来 public class ListViewForScrollView extends ListView{ public ListViewForScrollView(android.content.Context context,android.util.AttributeSet attrs){ super(context, attrs); } //设置不滚动 public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } }