1

I created a simple layout file in android studio as below:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <EditText
        android:id="@+id/NameEditText"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</LinearLayout>

when I press ALT+CTRL+L (Reformat) android studio changes my code to:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

    <EditText
        android:id="@+id/NameEditText"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

</LinearLayout>

as you may noticed, button's position has been changed from end to first and edittext's position changed from beginning of code to end of code!

could you please tell me is this behavior a bug or not? and if is not a bug, how can config android studio to behave normal?

Homayoun Behzadian
  • 1,053
  • 9
  • 26

1 Answers1

2

File > Settings > Editor > Code Style > XML > Arrangement (tab) > Force rearrange => Never

Homayoun Behzadian
  • 1,053
  • 9
  • 26