Google Documents:
Getwidth ():
Return the width of the your view.
Returns:The width of your view, in pixels
Getmeasuredwidth ():
The width of this view as measured in the most recent call to measure (). this shoshould be used during measurement and layout calculations only. use getwidth () to see how wide a view is after layout.
Returns:The measured width of this view
Prerequisites:
1. During class initialization, the actual size of the view is not obtained in the constructor (I have tested it, indeed ). You can try it. The getwidth () and getmeasuredwidth () results are both 0, but they can be obtained from the ondraw () method or the dispatchdraw () method. You can call invalidate () to execute the ondraw () and dispatchdraw () methods.
2. The unit of the results obtained by these two methods is pixel.
Correct understanding:
Getwidth (): the width of the entire view after the layout is set.
Getmeasuredwidth (): The width occupied by the View content after the content on the view is measured. The premise is that you must call Measure () in the onlayout () method of the parent layout or the ondraw () method of this view; (the value of the Measure parameter can be defined by a friend ), otherwise, the result obtained is the same as that obtained by getwidth.
The main difference between the two methods is whether the measure () method is used, and the position used by measure () is also important.
The difference between getheight () and get measuredheight () is the same.
Refer:[Original] Positive Solutions for Android getwidth and getmeasuredwidth