1

我将我的 Android Studio 更新到 3.5 版,目前当我按下 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">

    <data>
        ...
    </data>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <androidx.appcompat.widget.AppCompatButton
            style="@style/TransferButtonStyle"
            android:drawableTop="@{storeInfo.icon}"
            android:text="@{storeInfo.name}"
            tools:drawableTop="@drawable/ic_axidrop" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@color/grey_80_opacity"
            android:layout_gravity="center_horizontal"
            android:textSize="12sp"
            android:text="@{storeInfo.category}"
            tools:text="Jewellery" />
    </LinearLayout>
</layout>

重新格式化代码后:

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:text="@{storeInfo.category}"
            android:textColor="@color/grey_80_opacity"
            android:textSize="12sp"
            tools:text="Jewellery" />

        <androidx.appcompat.widget.AppCompatButton
            style="@style/TransferButtonStyle"
            android:drawableTop="@{storeInfo.icon}"
            android:text="@{storeInfo.name}"
            tools:drawableTop="@drawable/ic_axidrop" />
    </LinearLayout>

    <data>
        ...
    </data>
</layout>

这打破了我的看法。它看起来像 Studio 或编辑器规则中的错误。有人知道如何解决吗?

4

0 回答 0