Negative field demo:

Scenario
Overlapping views by setting a negative field on one of them so that it invades the bounding box of the other view.
Thoughts
It seems to work as you expect, with overlapping layouts if necessary. But I do not want to face a more serious problem, because I do not know what to do. Emulators, physical devices, you name it, when you use negative fields, everything seems to work correctly, one view invades the other bounding box of the views and depending on how it is declared in the layout, it will be above or below another view.
I also know that with API 21 we can set translationZ and elevation to make the view higher or lower than other views, but my problem mainly comes from the fact that the documentation for the layout_margin attributes clearly states that the margin values must be positive , let tell me:
Excerpts:
Specifies the extra space on the left, top, right, and bottom sides of this view. This space is beyond this point of view. Margin values must be positive . There must be a dimension value, which is a floating point number added using a block such as "14.5sp". Available units are: px (pixels), dp (density independent pixels), sp (scaled pixels based on preferred font size), in inches, mm (millimeters) ...
In those years when I asked this question, I did not have any problems with negative margin, I tried to avoid using them as much as possible, but did not encounter any problems, so even if the documentation says that I'm not too worried about this one.
android android-layout user-interface overlap margins
Juan Cortés May 20 '12 at 12:43 2012-05-20 12:43
source share