在Eclipse中
如果我们想让一段代码格式变得整齐,可以:
- 选中这行代码→右键单击→Source→Format
- 或者Ctrl+Shift+F就可以了
在Android Studio中
如果我们想让一段代码格式变得整齐,可以:
- 选中这行代码→Code→Reformed Code
- 或者Ctrl+Alt+L就可以
如下图:
Android Studio中的一个小技巧:
对于一段非常零碎的代码,格式化后行间距等仍然很不顺眼,可以尝试先把代码合并成一行之后再格式化。
命令 | 快捷键 |
---|---|
将代码合并成一行 | Ctrl + Shift + J |
格式化 | Ctrl+Alt+L |
文章评论
I have admired this cuff since the moment I saw it. It speaks to me like the tide coming in at a tropical paradise. I respect the ocean and would treat this cuff with perfect admtiarion. Please pick me to take care of it and spread the word about peace, love and Mimi Boutique.
Hey, yahoo lead me here, keep up nice work.