MeasureSpecMode 的三个值都是什么意思?
来源:互联网 发布:mac的快捷键 编辑:程序博客网 时间:2024/05/01 09:34
Section1
查看View源码中的
/** * Extracts the mode from the supplied measure specification. * * @param measureSpec the measure specification to extract the mode from * @return {@link android.view.View.MeasureSpec#UNSPECIFIED}, * {@link android.view.View.MeasureSpec#AT_MOST} or * {@link android.view.View.MeasureSpec#EXACTLY} */@MeasureSpecModepublic static int getMode(int measureSpec) { //noinspection ResourceType return (measureSpec & MODE_MASK);}
Section2
继续朝上找,有如下变量,
private static final int MODE_SHIFT = 30;
/** * Measure specification mode: The parent has not imposed any constraint * on the child. It can be whatever size it wants. */public static final int UNSPECIFIED = 0 << MODE_SHIFT;/** * Measure specification mode: The parent has determined an exact size * for the child. The child is going to be given those bounds regardless * of how big it wants to be. */public static final int EXACTLY = 1 << MODE_SHIFT;/** * Measure specification mode: The child can be as large as it wants up * to the specified size. */public static final int AT_MOST = 2 << MODE_SHIFT;
这三个值是多少呢?
Section3
public static void main(String args[]){ System.out.println(getFullBinaryString(UNSPECIFIED)); System.out.println(getFullBinaryString(EXACTLY)); System.out.println(getFullBinaryString(AT_MOST));}public static String getFullBinaryString(int num){ char [] mChars = new char [32]; for (int i = 0;i<32;i++){ mChars[31-i]= (char)((num>>i&1)+'0'); } return new String (mChars);}
打印结果如下:
09-26 18:24:07.975 8120-8120/? I/System.out: 0000000000000000000000000000000009-26 18:24:07.975 8120-8120/? I/System.out: 0100000000000000000000000000000009-26 18:24:07.975 8120-8120/? I/System.out: 10000000000000000000000000000000
========================================================
可以看到,这个其实就是利用了32位的int值的左侧两位存了 这三种状态。
顺便说下:
UNSPECIFIED 未指定
EXACTLY 指定
AT_MOST 指定了最大值
阅读全文
0 0
- MeasureSpecMode 的三个值都是什么意思?
- delphi 里的@^#等符号都是什么意思?
- delphi里的 @ ^ # 等符号都是什么意思?
- [copy]oracle数据库的服务都是什么意思
- eclipse新建项目时JRE的三个选项分别是什么意思?
- __try __finally都是什么意思?
- SVN上箭头都是什么意思,红色灰色蓝色的
- SVN上箭头都是什么意思,红色灰色蓝色的
- Linux执行top命令后看到的参数都是什么意思
- Python 里的 "%s 和 % d" 都是什么意思?
- BIOS里优先开机装置的可用选项都是什么意思
- appstore中关于idfa的选项都是什么意思
- appstore中关于idfa的选项都是什么意思
- App Store中关于idfa的选项都是什么意思?
- 手机的内核版本、基带版本等都是什么意思?
- SVN上箭头都是什么意思,红色灰色蓝色的
- apache 的配置文件hthp.conf里边都是什么意思?
- __declspec,__cdecl,__stdcall都是什么意思?
- 注解式框架--Butterknife的使用
- IAR 问题集
- 关于在caddy环境下,使用https协议UC无法下载的解决方法。
- 树莓派spi超频的方法
- Java动态代理机制详解(JDK 和CGLIB,Javassist,ASM)
- MeasureSpecMode 的三个值都是什么意思?
- 300.19读取一个文件中各字出现的次数
- 改变一生的闪念
- Redis主备复制环境的搭建
- java---Arrays类
- 分布式锁实现zookeeper原理
- 开源网站:代码搜索网站
- YTU OJ 2248: 栈的基本运算(栈和队列)
- Maven的POM文件配置积累