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!

This entry was posted in New Features and tagged , , . Bookmark the permalink.

3 Responses to Android Code Styles in IntelliJ IDEA 12

  1. Fredrik says:

    Great!

  2. Nagesh says:

    When can we expect UI editor for manifest file (like eclipse’s) ..

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">