【发布时间】:2019-08-21 07:03:14
【问题描述】:
在更新我的 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>
但是在更新 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>
在每个设计 XML 文件和 AndroidManifest.xml 文件中都进行了更改。
那么如何用旧方法做到这一点?
【问题讨论】:
-
我遇到了和你@Mayur 完全相同的问题。我通过转到 Preferences > Editor > Code Style > XML > Tab: Arrangement > Additional settings: Force rerange: Never 来修复。
-
这里已经回答了 - stackoverflow.com/questions/57591080/…
标签: android android-studio android-layout