Return to Video

So Much Real Estate Part 2

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

more » « less
Video Language:
English
Team:
Udacity
プロジェクト:
UD855 - Android Fundamentals 2
Duration:
01:57

English subtitles

改訂 Compare revisions