alexpfx alexpfx - 9 days ago 5
Android Question

Xml files in Android Studio - Remove spaces inside tags in layout files

On Android Studio is there a way to remove unnecessary spaces between the attributes and 'end tags' (">" and "/>") when formating xml files?

I can't see this configuration "Code Style" options.

enter image description here

Based on the accept answer below I got a configuration that work for me:

enter image description here

Answer

In Android Studio's Preferences, go to Editor > Code Style > XML. Then select the Android tab on the far right. There are options in this tab to customize the formatting of Android XML files (manifest, layouts, etc.). Make sure Use custom formatting settings for Android XML files is checked. Then you can just format that file like you do any other file Code > Reformat Code.

To get rid of the space before closing tags, go to the Other tab. Under Spaces make sure In empty tag and After tag name are un-checked.

enter image description here