码迷,mamicode.com
首页 > 移动开发 > 详细

Android开发(三十)——ScrollView中ListView的高度自动适应

时间:2015-07-04 16:41:17      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:

 

int totalHeight = 0;
for (int i = 0; i < mStrings.length; i++) {
    //pullList ListView
    //mAdapter Adapter
    View listItem = mAdapter.getView(i, null, pullList);
    listItem.measure(0, 0);
    totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = pullList.getLayoutParams();
params.height = totalHeight
        + (pullList.getDividerHeight() * (mAdapter.getCount() - 1));
pullList.setLayoutParams(params);


参考:

1. http://wfkbyni.iteye.com/blog/1545120

Android开发(三十)——ScrollView中ListView的高度自动适应

标签:

原文地址:http://www.cnblogs.com/ccdc/p/4620847.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!