ScrollView嵌套ListView,禁止ListView的滚动,只让ScrollView可以滚动

时间:2023-11-11 19:43:08

自定义ListView,xml布局文件中使用该自定义的ListView

public class NoScrollListview extends ListView{

        public NoScrollListview(Context context, 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);
}
}