'Command and Property order for "Margin" and "Padding" in Android Java Code

I previously asked:
Is it possible to set the "Margin" and "Padding" in Android XML with just one line each.

... and according to @MikeM.'s comment, it seems like that is not possible to do with XML.

Now to the same question but with Java code instead:


Lets say you have an ImageView or a Button in an Andriod ConstraintLayout.

Is it possible to set the "Margin" & "Padding" properties just with one command each in Java code? E.g.

layoutParams.margin="15,25,20,10"
layoutParams.padding="1,2,3,4"

And in what order would the properties then come?

  • Top, Bottom, Left(Start), Right(End)?
  • Left(Start), Top, Right(End), Bottom?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source