Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design tag order change in android studio while Rearrange/Reformat(command+ALT+L) the code [duplicate]

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?

like image 868
Mayur Patel Avatar asked Aug 21 '19 07:08

Mayur Patel


People also ask

How to Reformat the code in Android Studio?

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).

What is Rearrange code in Android Studio?

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.


1 Answers

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

like image 54
Elliott Smith Avatar answered Oct 06 '22 02:10

Elliott Smith