Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected auto-formatting of XML layout in Android Studio

I am using AS since 4 years. After last update I observed unexpected auto-formatting of XML layout (while typing and with Code -> Reformat Code too).

Here is an example:

  1. When I started typing relative layout, it expanded start tag, width property, height property and closing tag in the same line.
  2. Properties starts after indentation.
  3. No space between views after reformat.

Question

  • Is this a feature in new AS? then how can I revert it back?
  • Did I change some setting? What setting should I modify to revert back? (I tried to find on google but could not find anything)

enter image description here

I am using Android Studio 3.2.1 Build #AI-181.5540.7.32.5056338, built on October 8, 2018

like image 826
HBB20 Avatar asked Oct 17 '18 11:10

HBB20


People also ask

What is Android XML layout?

Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts. You can also use Android Studio's Layout Editor to build your XML layout using a drag-and-drop interface. Instantiate layout elements at runtime.

Where is the main XML file in Android Studio?

You will find out this file inside the res folder and inside it there is another folder named layout where you will get all the layout files for their respective activities or fragments.

What is XML code in Android Studio?

XML stands for eXtensible Markup Language, which is a way of describing data using a text-based document. Because XML is extensible and very flexible, it's used for many different things, including defining the UI layout of Android apps.


1 Answers

Update

if you facing same issue with Android Studio 3.5 please check below article

Android Studio 3.5 Upgrade XML Reformatting Problems

Open File > Settings > Editor > Code Style > XML

Now in layout file make sure you have selected wrap attributes as Wrap always

Like below screenshot:

enter image description here

like image 157
AskNilesh Avatar answered Oct 09 '22 04:10

AskNilesh