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:
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:
the specific solution is as follows:
- Settings–>Editor–> Code Style–>XML
- Click on the upper right corner Set from-> Predefined Style select Android Click OK to save, Perfect!
Then formatting code, the effect of what we want