So upgraded to Android Studio 3.5 yesterday, and it brought weird problem while auto-formatting XML layouts.
All the views inside a layout change order when Auto Formatted. So, if the views are inside LinearLayout
, then they'd change their order and all the similar type of views come together. And I just used LinearLayout
as an example, it happens everywhere in XML.
I tried Unexpected auto-formatting of XML layout in Android Studio this, but it didn't work for me. Is it a bug in Android Studio itself? Or did I mess some settings up while upgrading?
Here's the video of that happening https://youtu.be/1emrQFksg30. I pressed Ctrl+Alt+L for auto formatting.
This is especially a problem in LinearLayout
as order of elements is important in that. I used ConstraintLayout
as I was in kind of hurry to test something in my app.
Important:
See the comment below by @kAliert below if you don't want to jump around to find the answer (because some people marked this question as duplicate).
Edit: This question is about the problem that I faced in my layout, the question whose duplicate this question is supposed to be, is speaking of Android Manifest (which is XML too, but not many people will face that problem, as many people will be refactoring the layouts as compared to the manifest file). I personally wasn't able to find the answer to my question even after searching because that question didn't contain anything related to layouts, and I searched for layouts, which is a lot bigger problem than refactoring of Manifest file.