Formatting Android code in eclipse

Source: Internet
Author: User

When we use Eclipse for Android development, we can import the profile file provided by Google, so that every time "ctrl+shift+f", the IDE will be able to format the code according to the official specifications.

Download

The profile file for Eclipse is in this location on GitHub:

Https://github.com/android/platform_development/tree/master/ide/eclipse

There are two profiles for Java:

    • Android.importorder: Used to automatically adjust the order of import statements;
    • Android-formatting.xml: Used to format the code.

Attachment Download: Http://files.cnblogs.com/files/duxiuxing/eclipse_android_profile.zip

Import
    1. Eclipse main Menu Window > Preferences, open Preferences windows;
    2. Import android-formatting.xml in "Java > Code Style > Formatter";
    3. Import Android.importorder in Java > Code Style > Organize imports.

Optimization Setup Recommendation 1: Maximum length of comments per line is not qualified

If your project is using Javadoc, it is recommended not to limit the maximum length of comments per line to avoid breaking the layout of the document because of line wrapping.

The setup steps are as follows:

    1. Open the editor window for profile ' Android ';
    2. On the comments page, set the maximum line width for comments to 999:
Recommendation 2: Maximum length per line of code is not qualified

The setup steps are as follows:

    1. Open the editor window for profile ' Android ';
    2. On the line wrapping page, set the maximum line width to 999:

Formatting Android code in eclipse

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.