In general, Java/Kotlin work with px
. There's no official documentation that I can find (or anything in the source code of ConstraintSet
or Constraint
) that says this outright.
If you look at the source code for ViewGroup.MarginLayoutParams
, however, you will find this code:
public MarginLayoutParams(Context c, AttributeSet attrs) {
...
int margin = a.getDimensionPixelSize(
com.android.internal.R.styleable.ViewGroup_MarginLayout_layout_margin, -1);
if (margin >= 0) {
leftMargin = margin;
topMargin = margin;
rightMargin= margin;
bottomMargin = margin;
}
...
}
It should be plain to see (from the call to getDimensionPixelSize()
) that the units for margin
here are px
. I think it is reasonable to say that MarginLayoutParams is the "original" source of truth for margins, and I would generally expect things that emulate this behavior (like ConstraintSet
) to follow the same pattern.
Note that ConstraintLayout.LayoutParams
is a subclass of ViewGroup.MarginLayoutParams
.