Before updating my android studio my code looked like this with Rearrange/Reformat(command+ALT+L) the code
Many of the users reported this issue here
https://issuetracker.google.com/issues?q=Ctrl%2BAlt%2BL
https://issuetracker.google.com/issues/139769915
Short cut for Reformat the code
Windows: Ctrl + Alt + L
Linux: Ctrl + Shift + Alt + L
macOS: Option + Command + L
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:fitsSystemWindows="true"
tools:context=".view.activity.UserFollowingActivity">
<data>
<variable
name="viewModel"
type="com.socket.chat.viewmodel.ConversionListVM" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
But after update the android studio my code order change while Rearrange/Reformat(command+ALT+L) the code
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:fitsSystemWindows="true"
tools:context=".view.activity.UserFollowingActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
<data>
<variable
name="viewModel"
type="com.socket.chat.viewmodel.ConversionListVM" />
</data>
</layout>
It was changed in every design XML file and AndroidManifest.xml file.
So how can do it that with the old way?
Automatically formatting code in Android Studio and IntelliJ To automatically format your code in the current source code window, use Cmd+Alt+L (on Mac) or Ctrl+Alt+L (on Windows and Linux).
Navigate to the file in which we have to format our code and then click on the shortcut key as Ctrl+Shift+Alt+L after clicking this key you will get to see the below dialog on your screen. Select the formatting options and your code will be formatted and rearranged according to selected options.
Just change this setting in preference > code style > XML and you are good to go. hope it helps. It is a bug in the latest 3.5 update.
Tap here to see setting image
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With