The Android Documentation says that there is two sizes for a view, the measured dimensions and thedrawing dimensions. The measured dimension is the one computed in the measure pass (the onMeasuremethod), while the drawing dimensions are the actual size on screen. Particularly, the documentation says that:
These values may, but do not have to, be different from the measured width and height.
So, my question is: what could make the drawing dimension be different of the measured dimension? If the onMeasure(int,int) method respects the layout requirements (given as the parameterswidthMeasureSpec and heightMeasureSpec, how could the SDK decides that the view should have a different drawing size?
Additionally, how/where in the Android Source Code the measured width/height is used to compute the drawing width/height? I tryed to look into the View source code, but I can't figure out how the measuredWidth/Height is used to compute the final width/height. Maybe it has something to do with the padding, but I'm not sure.
本文深入探讨了Android中视图的两种尺寸概念:测量尺寸与绘制尺寸,并通过具体实例对比了getWidth与getMeasuredWidth的区别及应用场景。


1626






