1

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

I know you can set the "Margin" & "Padding" properties in XML individually with:

android:layout_marginTop="15dp"
android:layout_marginBottom="25dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"

android:paddingStart="1dp"
android:paddingTop="2dp"
android:paddingEnd="3dp"
android:paddingBottom="4dp"

But can you set them all with just one line? E.g.

android:layout_margin="15,25,20,10"
android: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?
Ola Ström
  • 4,136
  • 5
  • 22
  • 41

1 Answers1

0

No in XML you cannot set them all in one line. But you can do that programmatically like this

Ruchi
  • 71
  • 3