4

is there any feature in Android Studio to align all XML attributes by '=' sign. I am unable to find any setting that would allow this.

un-aligned aligned
Just another code format fanatic who likes code readability.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Daksharma
  • 599
  • 1
  • 7
  • 9
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). BTW, it's "Thanks in advance", not "Thanks in advanced". – John Saunders Jan 31 '15 at 20:00
  • 3
    I've never actually seen anyone do this style of XML formatting for Android layouts. Not saying it's wrong or anything. Just never considered it. – Matt Logan Jan 31 '15 at 20:03
  • 2
    I have not seen it either but coding in objective-c allowed me to simply align everything which made readability so much more efficient for me. which was made easier by XAlign (https://github.com/qfish/XAlign) plug-in for Xcode. since i couldn't find a way to do this though i ask. when i manually did the alignment it helped a lot with readability for the xml code and made it easier to look thru the file quickly. just a personal pref. :) @MattLogan – Daksharma Jan 31 '15 at 20:10

2 Answers2

12

below code will align everything but not after = sign. for better answer here

Win/Linux:

Ctrl + Alt + L

Mac:

Option + Command + L

Community
  • 1
  • 1
Milon
  • 2,221
  • 23
  • 27
1

Try like this

Settings - Editor - XML

screenshot

reznic
  • 672
  • 6
  • 9
  • Thanks, but am just nitpicking. there isn't really a solution, the alignment/wrap options allow for tags or attributes and even add spaces between equal sign but not necessarily for alignment of equal sign within the given attributes in the xml files. :D – Daksharma Apr 09 '18 at 21:00