在重新排列/重新格式化(命令+ ALT + L)代码的同时,在Android Studio中设计标签顺序更改

May*_*tel 5 android android-layout android-studio

在更新我的android studio之前,我的代码使用重新排列/重新格式化(command + ALT + L)看起来像这样

许多用户在这里报告了此问题

https://issuetracker.google.com/issues?q=Ctrl%2BAlt%2BL

https://issuetracker.google.com/issues/139769915

重新格式化代码的快捷方式

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>
Run Code Online (Sandbox Code Playgroud)

但是在更新android studio之后,我的代码顺序改变了,而重新排列/重新格式化(command + ALT + 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">

    <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>
Run Code Online (Sandbox Code Playgroud)

在每个设计XML文件和AndroidManifest.xml文件中均对其进行了更改。

那么如何用旧方法做到这一点呢?

小智 5

只需在首选项 > 代码样式 > XML 中更改此设置即可。希望能帮助到你。这是最新的 3.5 更新中的一个错误。

点按此处查看设置图像