关于android getWidth()和getMeasureWidth()的问题

view的onMeasure()中,为什么调用getWidth为0,调用getMeasureWidth得到的却不为0

请看这篇文章的分析:

 

①getMeasuredWidth方法获得的值是setMeasuredDimension方法设置的值,它的值在measure方法运行后就会确定

②getWidth方法获得是layout方法中传递的四个参数中的mRight-mLeft,它的值是在layout方法运行后确定的

③一般情况下在onLayout方法中使用getMeasuredWidth方法,而在除onLayout方法之外的地方用getWidth方法。
————————————————
版权声明:本文为CSDN博主「奋斗之路」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/dmk877/article/details/49734869/