Padding with negative values used to work before, ...
# compose
z
Padding with negative values used to work before, now it crashes runtime (no compilation warnings given):
Copy code
LayoutPadding(bottom = (-10).dp, end = (-5).dp)
Beyond the crash, what's the suggested way to achieve the same positioning?
java.lang.IllegalArgumentException: Padding must be non-negative
l
@Mihai Popa what’s our recommendation here? depends on the use case??? @Zsolt what is it you’re trying to do? Are you trying to “undo” another padding, or are you trying to actually do like a negative offset? I think we have an Offset modifier now which will allow negative values
z
No undoing, just positioning background decorations so that they're slightly off the screen. LayoutOffset works fine, thanks!
Minor ux complaint: it doesn't have default values of 0.dp, so you always need to specify both x and y values.
l
yeah, good point
m
Yes,
LayoutOffset
is the correct replacement for any padding that is only intended to offset the position
Thanks for the feedback regarding the API, we had deliberately decided to not put defaults, but your input is useful as we might decide to change it in the future 🙂