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.

3
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on Stack Overflow. See "Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?. BTW, it's "Thanks in advance", not "Thanks in advanced". Commented Jan 31, 2015 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. Commented Jan 31, 2015 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 (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 Commented Jan 31, 2015 at 20:10

2 Answers 2

13

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

Win/Linux:

Ctrl + Alt + L

Mac:

Option + Command + L

Sign up to request clarification or add additional context in comments.

3 Comments

Not Works to me!
Tey Ctrl + Alt + L on Ubuntu & locks my computer!
Worked on my Mac like a charm!
1

Try like this

Settings - Editor - XML

screenshot

1 Comment

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.