Lifecycle of view

If we see in the above flow there are three main parts in the lifecycle of view. Measure, Layout and finally draw. All of this happens on UI thread. View Group is like a tree which is traversed in a pre-order manner. Parent view group is responsible for asking its children to be drawn.

Measure Pass

This is a top-down pass in view tree. After this pass, all views have stored their measurements. If you override this method then you need to set measureHeight and measureWidth of the view. A parent view might call measure more than once on its child view

Layout Pass

After each view knows its measurement now is the time to calculate where they will get placed on the screen. This is also a top-down pass of view tree. During this, each parent is responsible for positioning each of their children using measurement calculated in measure pass.

Draw

It actually provides you with canvas as a parameter on which you can draw shapes, path, lines using Paint. Since now after layout pass position of each view is known on the screen parent asks each of its children to draw itself recursively

This is the basic lifecycle of a view now everything happens on a UI thread it's very important that all of this happens fast. Android refreshes its screen after every 16ms so if at this time UI thread is not free we see the drop in frame rate. Which provides a hanging experience or may even lead to ANR.