标签:scrollview 滑动 listview 布局
/**
* scrollview与listview合用会出现listview只显示一行多点。此方法是为了定死listview的高度就不会出现以上状况
* 算出listview的高度
*/
public static void setListViewHeight(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null) {
return;
}
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(1, 1);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)) + listView.getPaddingTop() + listView.getPaddingBottom();
listView.setLayoutParams(params);
}
拭心记于2015/5/27 http://blog.csdn.net/u011240877
ScrollView+ListView滚动冲突,没有滑动效果 解决办法
标签:scrollview 滑动 listview 布局
原文地址:http://blog.csdn.net/u011240877/article/details/46051669