Features

Android Code Styles in IntelliJ IDEA 12

If you are developing for Android, you probably deal with XML files every day. These are the manifests, layouts, drawables, resource files and many others. That’s why in IntelliJ IDEA 12 we have added a new option for the code formatter, which is aware of Android-specific code styles.

The new option is available in Settings → Code Style → XML and can be enabled via Set From… → Predefined Style → Android.

For instance, the IDE inserts line breaks in layout files before any internal tag and before the first attribute, if it is not a namespace declaration.

At the same time it does not insert line breaks before string resources or colors.

You might also notice, that the new formatter preserves user line breaks and doesn’t remove them.

In Android manifest the IDE groups tags with the same name. For example, you will get a single block of uses-permission tags. Note that the IDE does not rearrange tags, it just inserts and removes line breaks to group things together.

The default behaviour of the formatter can be changed anytime you want in the settings.

Please let us know what you think about the new code formatter on our discussion forum and in our issue tracker.

Develop with Pleasure!

image description