onMeasure学习整理
来源:互联网 发布:mac怎么重新分区 编辑:程序博客网 时间:2024/06/16 09:27
onMeasure函数如下:
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
onMeasure函数的调用者:
包含这个View的具体的ViewGroup调用,参数也就是从这个ViewGroup中传入的。
widthMeasureSpec与heightMeasureSpec来源与作用:
来源:
由ViewGroup中的layout_width,layout_height、padding、layout_margin和weight共同决定。
作用:
这两个值由高32位和低16位组成。高32位保存的值叫specMode,低16位的值叫specSize。分别可以通过getMode()和getSize()获取。
specMode类型:
- MeasureSpec.EXACTLY:LayoutParams.MATCH_PARENT。
- MeasureSpec.AT_MOST:LayoutParams.WRAP_CONTENT。
- MeasureSpec.UNSPECIFIED:我们可以随意指定视图的大小。
private static int getRootMeasureSpec(int windowSize, int rootDimension) { int measureSpec; switch (rootDimension) { case ViewGroup.LayoutParams.MATCH_PARENT: // Window can't resize. Force root view to be windowSize. measureSpec = MeasureSpec.makeMeasureSpec(windowSize, MeasureSpec.EXACTLY); break; case ViewGroup.LayoutParams.WRAP_CONTENT: // Window can resize. Set max size for root view. measureSpec = MeasureSpec.makeMeasureSpec(windowSize, MeasureSpec.AT_MOST); break; default: // Window wants to be an exact size. Force root view to be that size. measureSpec = MeasureSpec.makeMeasureSpec(rootDimension, MeasureSpec.EXACTLY); break; } return measureSpec; }
0 0
- onMeasure学习整理
- onMeasure学习笔记
- 个人学习笔记 onMeasure
- 学习日志-onMeasure等问题
- onmeasure
- onMeasure
- onMeasure
- onMeasure
- OnMeasure()
- onMeasure
- onMeasure
- View的onMeasure()的学习记录
- ViewGroup的onMeasure()的学习记录
- View的测量过程学习onMeasure
- 自定义View学习笔记之onMeasure()方法
- android学习日志--View中的onMeasure
- 自定义View之OnMeasure方法学习
- android onMeasure测量过程中MeasureSpec学习
- pi image shrink
- iOS VFL为scrollview添加约束
- Hadoop-分布式文件系统概述
- 在云服务器上部署项目
- java使用js引擎例子
- onMeasure学习整理
- Unity使用Random每次生成与上次不一致的随机数
- Mac开发
- android 系统UI模式的判断
- ThinkPHP框架模板文件中导入css,js文件相关问题
- 选择器
- C++ 程序 startup code 相关
- uml 类图依赖与关联的区别
- Git 推送本地仓库到GitHub