您的位置:首页 > 移动开发 > Android开发

Android 一张图理解getWidth和getMeasuredWidth

2013-06-19 10:29 387 查看
实际上在当屏幕可以包裹内容的时候,他们的值相等,只有当view超出屏幕后,才能看出他们的区别:getMeasuredHeight()是实际View的大小,与屏幕无关,而getHeight的大小此时则是屏幕的大小。当超出屏幕后,[b]getMeasuredHeight()等于getHeight()加上屏幕之外没有显示的大小[/b]

getwidth() is used to get width of view that has drawn like (view.getwidth() or view.getheight()).getwidth
()
 and getHeight
()
 will only be populated after the Layout Phase, that is after
onLayout()has been called.

getMeasureWidth() is used to get width of view that not drawn yet. like getmeasuredwidth() and getmeasureheight(). example : First call measure view.measure(0,0) and then u can use it with getmeasuredwidth() and getmeasureheight().

should not use getwidth/getHeight the values within onMeasure() or getMeasureWidth
()
/getMeasureWidth
()
, since those are only the dimensions the View is initially
offered or would like to have, not necessarily the ones it actually ends up getting.
http://www.cnblogs.com/zhuqiang/archive/2013/03/10/2952797.html http://blog.sina.com.cn/s/blog_6e519585010152s5.html http://blog.csdn.net/chongshi007/article/details/8985063 http://blog.csdn.net/johnny901114/article/details/7839512 http://www.bdqn.cn/news/201304/8749.shtml
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: