A brief analysis of Android View

Source: Internet
Author: User

Based on the source code analysis on Android 4.4:

Setcontentview Process:

GetWindow ()->setcontentview (), Installdecor () AddView ()

GetWindow () returned the Phonewindow

Installdecor () generates the window's Rootview Decorview

AddView () will result in Performtraversals () Decorview, Requestlayout (), Getviewrootimpl ()

Performtravsals () The workflow is done recursively:

Draw () measure (), Layout ()

Measure () different ViewGroup type measurement process (framelayout, linearlayout, relativelayout, etc.)

Framelayout as long as the measurement of all sub-view a piece, the speed of measurement is the fastest

LinearLayout is also a single measurement of all sub-view, but it is necessary to re-measure the maximum width or height again when there is a weight attribute

So specifying layout_width= "0DP" or layout_height= "0DP" when writing layout can reduce measurement time

Relativelayout requires a lateral and longitudinal measurement of the pair view. The measurement speed is the slowest, especially when the hierarchy is deep.

Layout () is basically to determine the individual view in the canvas coordinates.

Draw () generates displaylist to generate images for the GPU.

For ViewGroup with multiple sub-view, start with the bottom sub view (index:0) measure, layout, draw.

A brief analysis of Android View

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.