// ListView 自适应高度
int totalHeight = 0;// 总的高度
for (int i = 0; i < adapter.getCount(); i++) {
View listItem = adapter.getView(i, null, vListSize); // list1,当前listview
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = vListSize.getLayoutParams();
params.height = totalHeight
+ (vListSize.getDividerHeight() * (adapter.getCount() - 1));
vListSize.setLayoutParams(params);
ListView 自适应高度
最新推荐文章于 2023-09-30 14:01:07 发布