Obsolete
Status Update
Comments
ra...@google.com <ra...@google.com>
vi...@google.com <vi...@google.com> #2
Workaround: Go to Settings > Editor > Code Style > XML, and choose Set From > Predefined Style > Android.
ca...@gmail.com <ca...@gmail.com> #3
That workaround doesn't work for me.
Description
Build #AI-191.8026.42.35.5791312, built on August 8, 2019
JRE: 1.8.0_202-release-1483-b49-5587405 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 5.0.0-25-generic
Version of Gradle Plugin: 3.5.0
Version of Gradle: 5.4.1
You are getting a rash of issues regarding reformatting XML files changing the order of elements, such as:
-
-
-
The original issue seems to be
Based on some experiments, this seems to be a problem with upgrading from Android Studio 3.4 to 3.5. A fresh installation of Android Studio 3.5 does not exhibit the problem.
On an environment that I upgraded from AS 3.4 to 3.5, I get the XML arrangement rules shown in the AS-3p5-xml-bug.png screenshot (attached). In that environment, reformatting XML via Ctrl-Alt-L will result in reordering the XML elements to be alphabetical within each level of the XML hierarchy. This is bad, as XML element order matters in lots of places.
The current community workaround is to go to Settings > Editor > Code Style > XML, and choose Set From > Predefined Style > Android in there. That gives you the XML arrangement rules shown in AS-3p5-xml-fixed.png (attached), and elements are not reordered. Note that these rules all have "attribute" bubbles, whereas the broken rules do not.
Ideally, an upgrade from 3.4 to 3.5 would result in a working set of XML arrangement rules.
Thanks for considering this!