android代码格式化方法小结
转载:http://blog.csdn.net/androidzhaoxiaogang/article/details/7692526
-
Download the android-formatting.xml file
-
Open Eclipse and go to Window->Preferences->Java->Code Style->Formatter
-
Import the android-formatting.xml file and make sure “Android” is selected in the drop down list
-
In eclipse go to Window->Preferences->General->Editors->Text Editors
-
Check “Insert spaces for tabs” and make sure that “Displayed tab width” is 4
-
Check “Show print margin” and make sure that “Print margin Columns” is 100
-
Check “Show Whitespace characters” (如果不想显示空格的童鞋,可忽略这步)
-
In eclipse go to Window->Preferences->Java->Editor->Save Actions
-
Check “Perform the selected actions on save”
-
Check “Additional Actions” than hit configure
-
Under the “Code Organizing” tab check “Remove trailing whitespace” for all lines and “Correct Indention”
-
Under the “Code Style” tab remove all check marks
-
Under the “Missing Code” tab check everything
-
Now go to Window->Preferences->XML->XML Files->Editor
-
Check “Split multiple attributes each on a new line”
-
Check “indent using spaces” and make sure the value is set to 4