ListView 自适应高度


// 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);

猜你喜欢

转载自zheyiw.iteye.com/blog/2092884