I position lots of items relative to a layout guide, and would like to position a new item nearly relative to this layout guide.
I tried with a negative layout margin without success.
Support for setting negative margin in a ConstraintLayout
has been added in ConstraintLayout 2.1.0 alpha 2 on the 17th of December 2020.
You can update to it by setting the dependency to:
implementation 'androidx.constraintlayout:constraintlayout:2.1.0-alpha2'
The full changelog is available here: https://androidstudio.googleblog.com/2020/12/constraintlayout-210-alpha-2.html which includes:
ConstraintLayout
- supports negative margins for constraints
This means that now you can do things such as android:layout_marginTop="-25dp"
, which you couldn't do before!