Sign in Go Pro

Custom Views and ViewGroups

Custom Views and ViewGroups (Part 5) - How onLayout Works

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next



Explanation of where `onLayout` fits in the Android view drawing process. Reviews how the parent interacts with its child views through its own `onMeasure` and `onLayout` methods as discussed in previous methods. Reviews why `onLayout` is required for building custom ViewGroups. Includes a high-level description of how the `onLayout` method is called, the purposes of its parameters, and a general strategy for how to layout children inside of `onLayout`. Explains why it's important to call `layout` on child views and how to incorporate previously calculated measured width and height values into `onLayout`.

Lessons in Custom Views and ViewGroups