9-Nov-12 (Created: 9-Nov-12) | More in 'Custom Components in Android'

Custom layouts: Research, Theory, Code snippets, Images

Here are steps involved in creating a custom layout

Inherit from ViewGroup
Override OnMeasure
  Use a pencil and paper to figure out your algorithm
  Use ViewGroup.measureChild(). Don't directly use child.measure()
  (Unless you know what you are doing)
  Use layout params to stuff the origin of each child view
  Take into accound padding
Override OnLayout
  Just retrieve the layout param object and use its origin
Implement custom LayoutParams
Override layout params construction methods
Test it with exact, match parent, wrap content, and weights