Android View measure(0,0)的作用
来源:互联网 发布:姜卫鹏中超数据分析 编辑:程序博客网 时间:2024/05/21 17:00
将view.measure(0,0)设置为0的时候表示,此时不需要考虑父控件的布局问题,直接使用getMeasuredWidth和getMeasuredHeight获取此view的自身的实际大小,可以看下面的例子:这个是在网上引用的一段代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public
class
Utility {
public
static
void
setListViewHeightBasedOnChildren(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
if
(listAdapter ==
null
) {
// pre-condition
return
;
}
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);
}
}
1 0
- Android View measure(0,0)的作用
- Android View的Measure
- View[0] measure
- Android进阶系列0—View的工作流程:measure,layout,draw小结
- Android 从0开始自定义控件之 View 的 measure 过程(七)
- 浅析Android View的Measure过程
- Android View框架的measure机制
- Android应用程序窗口View的measure过程
- Android View的Measure过程(一)
- Android View框架的measure机制
- 【Android源码学习】View的measure流程
- Android View的measure过程详解
- Android View框架的measure机制
- (转)Android View框架的measure机制
- Android View ViewGroup 的measure过程
- Android View框架的measure机制
- Android View框架的measure机制
- Android View框架的measure机制
- C语言多线程
- NSFetchedResultsController调用时候crash
- Regexbuddy 4.5.0X64汉化版 下载
- React-native ListView缓存复用根本解决办法
- SQL简介&数据表分析&数据查询
- Android View measure(0,0)的作用
- Extjs的几种简单的提示框
- 返回顶部按钮
- java学习之编译时类型(前期绑定)和运行时类型 (后期绑定、动态绑定、运行时绑定)
- Web - web前段技术框架图
- 增加删除附件
- win2003 序列号 windows2003 sp2可用序列号大全(准版与企业版)
- BW实时抽取ECC数据的实现
- eclipse部署到tomcat出现class not found异常