The Material Design system has a lot of good resources explaining what a properly designed app is supposed to look like. What's lacking, in my opinion, is some kind of walk-through on how to best achieve this in an app.

Take this page about "Understanding layout", for example:

I do understand the grid system, the value of key lines and similar aspect ratios between various elements etc. - but when it comes to actually implementing this in a specific app... let's say it mostly works, but is messy.

For example, on Android the layout of any activity typically consists of

1. a top-most view group, for example a CoordinatorLayout, which holds a few key components such as an app bar, a floating action button and

2. a secondary view group as a direct child of the first one, for example a LinearLayout, that holds the content.

3. In turn, the content consists of a number of views and view groups again, with their layouts probably defined in separate files. These individual content layouts are sometimes added to an activity via XML, sometimes programmatically while the app runs on a user's device.

Each of these individual views and view groups allows to define either a padding (whitespace inside the container), or a margin (whitespace outside of the container), neither or both. In combination of all these values, there should be some fixed amount of whitespace - say 16dp - between the edge of the screen and the first pixel of a string or icon.

At first, it seems to be the easiest solution to define all of this whitespace to be a margin of the top-most layout. This doesn't work, because some of the individual elements need their own surrounding margin to work with, for example to render drop shadows.

Defining the margins of the top-most view groups to be 0, and then defining the necessary margin value for each low-level element individually solves the former issue, but can become messy when elements are reused in different contexts, or simply due to the repetition of the ever-same value everywhere. Combine this with the best practice to not define layout_* parameters in a style but always in the XML resource directly, and everything becomes even more bloated.

If you've ran into the same problem before - and chances are, if you've tried building an MD-compliant app layout you have, what's your strategy for dealing with this? Am I missing some obvious solution?