how to format XML code alphabetically in android studio?

I have this xml code. I want it to be organized alphabetically with Command + alt + L.

<ImageView
 android:id="@+id/logoImageView"
 android:layout_width="0dp"
 android:layout_height="150dp"
 android:scaleType="fitCenter"
 android:src="@drawable/ic_logo"
 app:layout_constraintTop_toTopOf="@+id/view"
 app:layout_constraintStart_toStartOf="parent"
 app:layout_constraintEnd_toEndOf="parent" android:layout_marginTop="64dp"
 android:layout_marginStart="32dp" android:layout_marginEnd="32dp" />

example

<ImageButton
 android:id="@+id/logoImageView"
 android:layout_width="0dp"
 android:layout_height="150dp"
 android:layout_marginStart="32dp"
 android:layout_marginTop="32dp"
 android:layout_marginEnd="32dp"
 android:background="@android:color/transparent"
 android:scaleType="fitCenter"
 app:layout_constraintEnd_toEndOf="parent"
 app:layout_constraintStart_toStartOf="parent"
 app:layout_constraintTop_toTopOf="parent" />

Upvotes: 1

Views: 467

Answers (1)

Elias Meireles
Elias Meireles

Reputation: 1058

If you're with Windows or Linux, press CRTL+ALT+S, got to -> Editor->Code Style, there is a dropdown Scheme... https://i.sstatic.net/T3vxF.png select the Default IDE and apply, back to your XML file and press CRTL+ALT+L, this should work, in case of Mac, i don't know yet.

Upvotes: 3

Related Questions