What is the difference between getMeasuredWidth and getWidth of View ?, Imageviewgetwidth0

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.