Sign in Go Pro

Custom Views and ViewGroups

Custom ViewGroups (Part 3): onMeasure Helpers

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next

Previous

About

In this lesson, we will look at four methods in the ViewGroup class that can help simplify onMeasure logic when creating a base ViewGroup class:

  • getChildMeasureSpec for helping calculate MeasureSpec values for child views given the ViewGroup's own MeasureSpec values and the LayoutParams of the child
  • measureChild/measureChildren for simply measuring children whose size and position are independent of other views, like in FrameLayout
  • measureChildWithMargin for measuring children while taking margins into account as well when the children's size and position depend on other views as in LinearLayout
  • How do all of the measure helpers use getChildMeasureSpec to do the hard work
  • When do we want to use each helper method

Instructor

Links

Comments

There are no comments on this lesson, start the conversation below ...

>
You need to go PRO to post comments.

Lessons in Custom Views and ViewGroups