/** * scrollview嵌套listview显示不全解决 * @param listView */public static void setListViewHeightBasedOnChildren(ListView listView) {ListAdapter listAdapter = listView.getAdapter();if (listAdapter == null) {// pre-conditionreturn;}int totalHeight = 0;for (int i = 0; i < listAdapter.getCount(); i++) {View listItem = listAdapter.getView(i, null, listView);listItem.measure(0, 0);totalHeight += listItem.getMeasuredHeight();}ViewGroup.LayoutParams params = listView.getLayoutParams();params.height = totalHeight+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));listView.setLayoutParams(params);

}

然后在setdapter以后调用该方法就解决问题了。

itemView 是 RelativeLayout时 异常处理:http://blog.csdn.net/ljz2009y/article/details/18351491

更多相关文章

  1. 在Tab里面使用Android(安卓)TTS引擎的问题
  2. android调用系统(相机)的图片,并且返回
  3. Android中多层Fragment嵌套,调用相册返回Uri无法显示图片的问题解
  4. android调用浏览器打开网页链接
  5. Android(安卓)全屏无标题详解
  6. Intent在Android中的几种用法
  7. Android调试工具 —— TraceView [整理]
  8. Android(安卓)- 解决onSaveInstanceState的Bug
  9. ANDROID ONTOUCHEVENT, ONCLICK及ONLONGCLICK的调用机制

随机推荐

  1. 如何在你的App中应用Material Design设计
  2. cocos2dx android 程序启动黑屏相关
  3. android 源码和兼容包
  4. Useful related java API for Android
  5. Android(安卓)去除标题栏
  6. Android里面从Dialog中获取返回值并写入
  7. android可视化视图无法显示layout控件
  8. Android(安卓)获得手机信息工具类
  9. Android怎么实现网易新闻的图文混排?
  10. [置顶] android 中使用回调函数