Reputation: 1391
I'm editing an open source project and find that a -1dp value for layout_marginTop is causing the graphical preview in Eclipse to fail with the error. The full error message, which probably includes an additional error, is:
java.lang.NullPointerException
"-1dp" in attribute "layout_marginTop" is not a valid format.
Exception details are logged in Window > Show View > Error LogThe graphics preview in the layout editor may not be accurate:
Paint.setShadowLayer is not supported. (Ignore for this session)
Do you know what the problem is?
Upvotes: 4
Views: 7042
Reputation: 39470
The reason is because in previous versions of the Android SDK negative margins were permitted (up to 2.2?). Negative margins previously elicited an "unspecified behavior" aka they actually moved the layout in the negative direction. I've used the functionality before and it's actually quite useful at times.
My guess is that (1) the layout is up against the edge of the screen and that's what causes the error or (2) negative margins are now longer allowed and they throw errors. I can't confirm that though.
I'd just change it to zero.
Upvotes: 2
Reputation: 13855
Quite simply put:
You cannot have a negative margin in your given situation
Due to this, your graphical preview does not know how to render it.
Upvotes: 2