1、

public  void setListViewHeight(){
ListAdapter listadapter = lv.getAdapter();
if (listadapter == null) {
return;
}
int totalHeight = 0;
for (int i = 0; i < listadapter.getCount(); i++) {
View listItem = listadapter.getView(i, null, lv);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}

ViewGroup.LayoutParams params = lv.getLayoutParams();
params.height = totalHeight + (lv.getDividerHeight() * (listadapter.getCount() - 1));
lv.setLayoutParams(params);
}

这个方法有时会报空指标的错

还是没有找到正确的解决方法

2、

给listView设置高度

3、

在 ScrollView 中 添加 android:fillViewport="true",这个方法是可行的

最新文章

  1. 实现AJAX的异步交互的步骤
  2. symfony2 安装并创建第一个页面
  3. Java 简介
  4. C# ASP.NET 开发指引简要
  5. sublime text 3 licence code
  6. JQuery调用iframe父页面元素与方法
  7. XOR双向链表
  8. 小鱼提问1 类中嵌套public修饰的枚举,外部访问的时候却只能Class.Enum这样访问,这是为何?
  9. Redis环境搭建
  10. WinForm响应式布局设计实践
  11. node创建第一个应用
  12. css高度自適應
  13. 【翻译】Flume 1.8.0 User Guide(用户指南) source
  14. Redis 的安装 使用 通知事件
  15. linux shell $ 特殊变量
  16. java json转换
  17. Matlab基本用法
  18. 修正eth0,解决虚拟机桥接问题
  19. 屏幕置顶(WindowManager服务)
  20. Python 分支、循环、条件、枚举

热门文章

  1. css新增样式
  2. Anaconda died after receiving signal 7
  3. Lamp(Ubuntu 12.04 LTS) 之 htaccess的使用
  4. 突破php的imagecopyresampled 和imagecopyresized 实现图片马JPG
  5. SAP语音读汉字
  6. .NET牛人需要了解的问题[转]
  7. onclick传递参数
  8. NAND flash sub-pages
  9. java selenium (十) 操作浏览器
  10. Apache AB 如何传递参数