English subtitles

← So Much Real Estate Part 2

Get Embed Code
5 Languages

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

  1. Once again, here's the design
    we're looking to create.
  2. What's great about this view is that
    it uses mostly UI elements we've seen
  3. before.
  4. In order to prevent the number
    of complex layouts from growing
  5. explosively, we're going to
    take advantage of three Android
  6. layout features.
  7. The first one we've seen before.
  8. The only difference between
    a forecast list item on the phone and
  9. on the tablet is padding and
    margins around the list items.
  10. Fortunately, it's easy to add
    this to the forecast list.
  11. We can use dimensions to give the same
    layout more space in tablet layouts.
  12. In forecast list item layout, we can add
    a padding dimension to the outer layout.
  13. We use padding here instead of margin
    because we just want the content in set.
  14. If we used margin,
  15. the row selector wouldn't be drawn
    across the entire list item.
  16. We also use a different dimension for
    the space between the two temperatures.
  17. Note that we use both right and
  18. end to make sure that this layout is
    ready for right to left mirroring.
  19. So then in our resource's file we
    create a dimension that updates
  20. the extra padding and
    the space between the two temperatures.
  21. And that layout is updated.
  22. I'm using sw600dp-port.
  23. Which means that these changes will
    only be applied Portrait Orientation
  24. with devices and a view sides
    with at least a width of 600 dp.
  25. The second thing we take advantage of
    is Layout Reuse using the include tag.
  26. We can see that our portrait and
  27. landscape detail fragment
    use the same views.
  28. The fragment detail view contains
    these included lay outs already.
  29. Note that we can assign new lay out
    parameters when we include the lay out.
  30. We're not using this in sunshine.
  31. But we can avoid adding an extra
    container when we include the layout by
  32. using the merge tag in
    the layout to be included.
  33. Finally, we're going to
    continue to make use of Refs.
  34. Refs allow us to make aliases for
    resources.
  35. As you can see,
    in tablet landscape mode,
  36. the detail view should point to
    a vertical version of the view.
  37. We're going to create a Ref that
    points to fragment_detail_start and
  38. make sure that it points to the correct
    detail fragment for all configurations.
  39. This will come in handy
    in the next lecture.