English subtitles

← Optimizing Layouts - Developing Android Apps

Get Embed Code
10 Languages

Showing Revision 15 created 05/25/2016 by Udacity Robot.

  1. Now that you know how to create
    an arbitrarily complex nested layout,
  2. it's important to understand
    that they don't come for free.
  3. Once again, the resource constraints
    of the platform spoil the party.
  4. Inflating complex layouts
    can be expensive,
  5. potentially impacting the performance
    and responsiveness of your app.
  6. So there are two good
    rules of thumb to help.
  7. First, keep your layout shallow and wide,
    rather than deep and narrow.
  8. That means you're better off
    with more siblings and fewer children.
  9. Because it's never as simple as that,
    you also want to avoid
  10. having excessive Views.
  11. In the most general terms,
    that means your activities'
  12. full hierarchy should never have
    more than ten nested Views
  13. or over 80 Views in total.
  14. That probably sounds like a lot,
    but let's open up
  15. the Hierarchy Viewer tool
    in Android Studio
  16. and see just how quickly
    that can add up.