Margins in group layouts do not seem to work.
For example,
The problem is actually the way FrameLayout
interprets margins. setContentView()
attaches your "main" layout to a FrameLayout
, which is the actual root of the view hierarchy (you can see that with Hierarchy Viewer) and is offered to you by the phone.
Margins are managed by the parent layout, so in this case that main FrameLayout
. I don't know if it's a feature or a bug, but that's how this layout interprets margins.
So well, the solution was already posted while I was typing: use padding instead.