Android ScrollView与ListView的冲突解决办法汇总
2024-08-26 10:40:06
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",这个方法是可行的
最新文章
- 实现AJAX的异步交互的步骤
- symfony2 安装并创建第一个页面
- Java 简介
- C# ASP.NET 开发指引简要
- sublime text 3 licence code
- JQuery调用iframe父页面元素与方法
- XOR双向链表
- 小鱼提问1 类中嵌套public修饰的枚举,外部访问的时候却只能Class.Enum这样访问,这是为何?
- Redis环境搭建
- WinForm响应式布局设计实践
- node创建第一个应用
- css高度自適應
- 【翻译】Flume 1.8.0 User Guide(用户指南) source
- Redis 的安装 使用 通知事件
- linux shell $ 特殊变量
- java json转换
- Matlab基本用法
- 修正eth0,解决虚拟机桥接问题
- 屏幕置顶(WindowManager服务)
- Python 分支、循环、条件、枚举