Android Studio: Reformat Code formatted Xml layout code out of sequence control

Android Studio 3.5 after the upgrade, a wonderful encounter problems after formatting codes in layout xml file, the order of the controls are changed, it's not the result we want, online search, I really was a pot AS3.5, each upgrade will encounter different problems, the first record about it, have the time to study why the adjustment made.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="16dp"
    tools:context="sun.geoffery.mvpdemo.MainActivity">

    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="点击按钮获取网络数据" />

    <Button
        android:id="@+id/getData"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="获取数据【成功】" />

    <Button
        android:id="@+id/getDataForFailure"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="获取数据【失败】" />

    <Button
        android:id="@+id/getDataForError"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="获取数据【异常】" />

</LinearLayout>

The simple layout interface generally as follows:
Unformatted layout position
go you, Ctrl + Shift + F, a format, look at our code:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="16dp"
    tools:context="sun.geoffery.mvpdemo.MainActivity">

    <Button
        android:id="@+id/getData"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="获取数据【成功】" />

    <Button
        android:id="@+id/getDataForFailure"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="获取数据【失败】" />

    <Button
        android:id="@+id/getDataForError"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="获取数据【异常】" />

    <TextView
        android:id="@+id/text"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:text="点击按钮获取网络数据" />

</LinearLayout>

TextView topmost original is formatted to the bottom, forcing face ignorant interface as follows:
After the default format AS3.5 changed control sequence
the specific solution is as follows:

  1. Settings–>Editor–> Code Style–>XML
  2. Click on the upper right corner Set from-> Predefined Style select Android Click OK to save, Perfect!
    Set up a profile
    Then formatting code, the effect of what we want
    After modifying the configuration, formatted layout position is that we want
Published 59 original articles · won praise 88 · views 190 000 +

Guess you like

Origin blog.csdn.net/geofferysun/article/details/100099016