View work progress Layout and Draw


Layout as the name,is to affirm the position of View,it include the position of View and it children view.

source code flow

layout method,call setFrame method to confirm own position,then call children View’s onLayout method to confirm their position.


onLayout method are different by different view,because different view have different child layout,for example, linearlayout have vertical and horizon two mode.


Draw will draw the view to screen

draw step

1.draw background  bacground.draw(canvas)
2.draw itself onDraw
3.draw children dispatchDraw
4.draw decorate   onDrawScrollBars

setWillNotDraw method

If call it to pass a true param, system will not draw this view,it’s false in most time,we can use it when the customer ViewGroup don’t need draw,can let system do some optimize.

A software developer

Leave a Comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.