[Android Studio] Formatting layout xml indents wrong

983 views
Skip to first unread message

Özcan Kaymak

unread,
Jan 28, 2014, 2:58:10 PM1/28/14
to adt...@googlegroups.com
When a layout is created it usually looks like this:

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

    xmlns:tools="http://schemas.android.com/tools"
    android:layout-width="match_parent"

    android:layout-height="match_parent"
    android:orientation="vertical">
...etc...

After formatting the file, it becomes like this:

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

              xmlns:tools="http://schemas.android.com/tools"
              android:layout-width="match_parent"

              android:layout-height="match_parent"
              android:orientation="vertical">
...etc...

This only happens to the root element. Other elements are ok.
Looks like a bug to me.

Özcan Kaymak

unread,
Jan 29, 2014, 11:32:02 AM1/29/14
to adt...@googlegroups.com
Also formatting the layout xml is not sorting the attributes. It is possible in Eclipse (see: this).
Is this going to be implemented, or do we have to set this in Android Studio (Code Style - XML - Attributes)?

Anton Rutkevich

unread,
Jan 30, 2014, 4:20:26 AM1/30/14
to adt...@googlegroups.com
This only happens to the root element. Other elements are ok.
Looks like a bug to me.
This can be changed in Preferences ->Code Style -> Xml -> Other -> Uncheck 'Align attributes'
But, yes, I think it should be unchecked by default. 
Reply all
Reply to author
Forward
0 new messages