Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio 3.5 refactor issue

You just need to set xml layout for Android applications from the settings.

Follow this steps:

1. Go to Android Studio > Preferences. For Windows, go to File > Settings.

enter image description here

2. Search for xml in search bar.

enter image description here

3. Under code style section, select xml tab.

enter image description here

4. In the top right corner, click on set from... and under predefined style, select Android

enter image description here

5. Click on Apply and try to refactor.


Reset the appropriate Android code style as follows.

For Windows Only

Step1: Click on the file menu.

Step2: Navigate to Setting.

Step3: Find Editor in the Left Panel**.

Step4: Find Code Style in the Sub Menu of Editor.

Step5: Click on XML in the Sub Menu of Code Style.

Step6: Click on Set from in Top right corner of Right panel.

Step7: Select Predefined Style.

Step8: Select Android.

Step9: Click OK.

For macOS Only

Step1: Click on the Android Studio menu.

Step2: Navigate to Preferences.

Step3: Find Editor in the Left Panel**.

Step4: Find Code Style in the Sub Menu of Editor.

Step5: Click on XML in the Sub Menu of Code Style.

Step6: Click on Set from in Top right corner of Right panel.

Step7: Select Predefined Style.

Step8: Select Android.

Step9: Click OK.


It seems the default scheme leaves out the "attribute" property in the arrangement rules. Adding them back in works like a charm for me.

The correction can be made in: Preferences > Editor > Code Style > XML enter image description here


Just adding more details .

This is a known issue with android studio from Android Studio 3.5 Canary 8 . It should get fixed in next version as this turned out to affect large number of developers .

You can see status of the bug here

Also the solution is

Broken XML code style

When editing XML code, the IDE might apply an incorrect code style when you select Code > Reformat Code from the menu bar. To fix this issue, reset the appropriate Android code style as follows:

  1. Open the Settings window by clicking File > Settings (on macOS, Android Studio > Preferences).
  2. In the left panel, click Editor > Code Style > XML.
  3. Near the top-right corner of the right panel, select Set from > Predefined Style > Android
  4. Click OK.

Which is found here -> Known issues with Android Studio and Android Gradle Plugin

Edit: This is now fixed in Android studio version 3.5.2