Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make namespace attr in XML code appear on the next line when reformatted

Every time I reformat my XML code, xmlns moves up to a line where root element's tag name is written.

<android.support.design.widget.CoordinatorLayout 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">

xmlns:android... is next to the CoordinatorLayout. I played with XML section of Code Style menu in AndroidStudio, but couldn't do it. This is what I want to have when I reformat my layout XML file:

<android.support.design.widget.CoordinatorLayout
     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">

Can someone help me with this?

This is the XML attribute arrangement in my AndroidStudio: XML attr arrangement

like image 786
amira Avatar asked Nov 18 '18 12:11

amira


1 Answers

  1. Go to File -> Settings -> Editor -> Code style -> XML.
  2. There are 4 submenus (Tabs and Intents, Other, Arrangement, Android), select Android.
  3. On the right side, below the Layout Files check both Insert line break before first attribure, Include namespace declarations.

enter image description here

like image 65
Muhammadjon Avatar answered Sep 20 '22 16:09

Muhammadjon