/**
* @param 自动匹配listview的高度
*/
public void setListviewHeight(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if (listAdapter == null) {
return;
}
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {
View listitemView = listAdapter.getView(i, null, listView);
listitemView.measure(0, 0);
totalHeight += listitemView.getMeasuredHeight();
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight
+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));
((MarginLayoutParams) params).setMargins(0, 0, 0, 0);
listView.setLayoutParams(params);
}安卓自动匹配listview的高度
原创海大易小晨 ©著作权
文章标签 匹配 安卓 listview高度 文章分类 移动开发
上一篇:安卓获取当前周的日期
下一篇:安卓连续按两次返回按钮退出软件
-
android listview 效果 listview 安卓
一个ListView布局的使用与显示,我们可以按照以下方法进行: 1. 创建带ListView控件的全局布局文件activity_main.xml:<LinearLayout xmlns:android="<a target=_blank href="http://
android listview 效果 android ListView List xml -
Android listview筛选 安卓listview的用法
1、为什么使用ListView: 我们使用new TextView对象显示数据的时候,会一次性查询大量的数据,创建大量的类对象保存数据,创建大量的TextView显示数据 这样我们手机的内存会接受不了。 为了节省内存消
Android listview筛选 使用方法总结 学习笔记 android xml

















