自己继承ViewGroup实现一个视图。重写protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
发现执行该函数时widthMeasureSpec值为1073742304,heightMeasureSpec值为-2147482923。这两个值是什么意思?谢谢。
发现执行该函数时widthMeasureSpec值为1073742304,heightMeasureSpec值为-2147482923。这两个值是什么意思?谢谢。
解决方案 »
- 请问, 这些是如何控制的? 要涉及些什么东西?
- android 中的cursor问题
- 关于HttpPost重定向的问题
- ListView.setupChild报错的问题
- android PDF阅读器
- sign-in/sync error
- 求安卓4.2 bluedroid OPP流程分析
- android 如何对从麦克风获取的数据进行处理
- android中import com.sun.image.codec.jpeg.ImageFormatException;出现错误
- 请问程序报这样的错该怎么解决呀?
- QQ那样的显示用户聊天记录listview怎么实现?
- 请教:我弄了个闹铃 还没到时间就直接到广播了
* 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;
private static final int MODE_SHIFT = 30; 那两个值是出自这个函数:
private int getRootMeasureSpec(int windowSize, int rootDimension) {
int measureSpec;
switch (rootDimension) { case ViewGroup.LayoutParams.FILL_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;
}
具体啥意思,我也在研究....
Log.d("ANDROID_LAB",
"onMeasure w_mode=" + MeasureSpec.getMode(widthMeasureSpec) + " w_size="
+ MeasureSpec.getSize(widthMeasureSpec) + " h_mode=" + MeasureSpec.getMode(heightMeasureSpec)
+ " h_size=" + MeasureSpec.getSize(heightMeasureSpec));
其中getMode()返回值为:EXACTLY。
http://www.google.com/codesearch/p?hl=en#uX1GffpyOZk/core/java/android/view/View.java&l=9019
由此推断楼主设备的屏幕分辨率为:725*480