English subtitles

← Altering the Layout - Solution

Get Embed Code
5 Languages

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

  1. All right!
    Your done.
  2. Lets go over my solution.
  3. Before we actually go to lay out
    the bottom half of our details view
  4. lets strategize.
  5. We have two columns,
    one that contains these headers, and
  6. one that contains data.
  7. The headers column is pretty
    easy it's all left justified,
  8. 32 dp away from the edge.
  9. The other column is also justified
  10. right from the other edge but all three
    of those elements are aligned left.
  11. This would be very tricky to do with
    anything else other then a grid lay out.
  12. We're going to let these three elements
    actually take up the expanded space.
  13. Let's look at how we implemented that.
  14. All right, so
    let's take a look at our grid layout.
  15. As you can see, the padding in
    the bottom and top is 16DPR.
  16. Abc_action_bar_content_inset_material.
  17. Our padding in left and
    right, in start at end, for
  18. right to left languages,
    is forecase_detail_horizontal_padding.
  19. Or 32DP as we defined
    it in our dimensions.
  20. Let's take a look at our first row and
  21. As you can see,
    we're using columnWeight 1.
  22. Let the layout manager know
  23. that this text view is actually going to
    expand to take up any additional space.
  24. We use a rowWeight of 1 to also show
    this row is going to participate in any
  25. additional space that
    the layout manager may have.
  26. And here's our first column.
  27. And here's our second column.
  28. Notice that we're not using
    any weights here at all.
  29. Other than that this is pretty simple,
  30. all of our rows have
    a row weight of one, so
  31. they'll all participate in the extra
    space, so they'll all be spaced evenly.
  32. This gives the layout a nice even look.
  33. And that's it.
  34. That's pretty straight forward.
  35. Again, there's not necessarily
    one solution to this.
  36. One of the things I like about layouts,
  37. is that each one of them is
    like solving a little puzzle.
  38. All right, it's running in the emulator.
  39. And there's our new detail view
  40. with that bottom section
    looking exactly as we intended.