Optimizing layouts with the Hierarchy Viewer

Before you can start optimizing your layouts, it helps to understand the Android layout process. Inflating a layout, begins when the activity first comes into display. Three steps occur:

  • Measure: This is where the Views determine their size, starting with the parent and working through all the children. The parent may have to call its children multiple times to work out the final size.
  • Layout: This is where the parent determines the position of its children
  • Draw: This is where the Views are actually rendered

This process starts with the parent, which then iterates through all its children. Those children iterate through their children. This creates the Layout Tree, with the parent becoming the root node ...

Get Android Application Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.