What is the difference between getMeasuredWidth and getWidth of View ?, Imageviewgetwidth0
GetMeasuredWidth indicates the measurement width of the view.
GetWidth is the final width of the view.
(The width and height are also discussed here)
So what are the differences between them?
The measurement width is formed in the measure process of the view, and the final width is formed in the layout process of the view.This is the difference between them. In most cases, their sizes are equal. They are not equal only in some cases. For example, the layout method of view is rewritten:
@ Override public void layout (int l, int t, int r, int B) {super. layout (l, t, r + 10, B + 10 );}
In this case, the final width and height will be 100px more than the measured width and height.
Another case is that the View must be measured multiple times to determine its measurement width and height. During the previous measurement, the measured width and height may be different from the final width and height, but in the end, the measurement width and height are the same as the final width and height.