首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

getWidth() 跟 getMeasuredWidth()的区别

2013-11-02 
getWidth() 和 getMeasuredWidth()的区别getWidth(): View在设定好布局后整个View的宽度。getMeasuredWidth

getWidth() 和 getMeasuredWidth()的区别
   getWidth(): View在设定好布局后整个View的宽度。
  getMeasuredWidth(): 对View上的内容进行测量后得到的View内容占据的宽度,前提是你必须在父布局的onLayout()方法或者此View的onDraw()方法里调用measure(0,0);(measure 参数的值你可以自己定义),否则你得到的结果和getWidth()得到的结果一样

热点排行