protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec,expandSpec);//设置gridview或者listview的onMeasure方法,使得gridview或listview的高度为它所需要的高度,这样listview和gridview就不需要滚动了
解决scrollview 嵌套gridview或者listview 冲突的问题
最新推荐文章于 2025-12-05 11:27:21 发布
本文介绍了一种通过设置GridView或ListView的onMeasure方法来调整其高度,从而避免滚动条出现的技术方案。通过实现MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE>>2,MeasureSpec.AT_MOST),可以确保GridView或ListView在加载内容时自动调整到所需高度,提供更流畅的用户体验。
297

被折叠的 条评论
为什么被折叠?



