Intellij Idea/Android Studio 中的 Android 代码风格 [英] Android Code Style in Intellij Idea / Android Studio

查看:38
本文介绍了Intellij Idea/Android Studio 中的 Android 代码风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android Studio 之前,我使用的是 android-formatting.xml 作为 Eclipse 中的代码样式.

如何设置 Android Studio/Intellij Idea 以像在 Eclipse 中一样格式化代码?

更新

我尝试了 Eclipse Code Formatter 插件.它似乎有效,但您根本无法编辑任何设置.我的团队更喜欢 120 列而不是 100 列.

我也试过@CrossleSong 的回答.这有点棘手,但更强大.你可以保存这个

https://android.googlesource.com/platform/development/+/android-4.2.2_r1.2/ide/intellij/codestyles/AndroidStyle.xml

as Android.xml 并将其复制到 AndroidStudio/Intellij codestyles 文件夹:对我来说是

~/Library/Preferences/AndroidStudioPreview/codestyles

现在您可以在 Android Studio 首选项中选择 Android 作为代码样式.

解决方案

您可以下载development

a> 来自 Android 源的 repo.development/ide/intellij 文件夹包括代码样式、模板...

Before Android Studio, I was using android-formatting.xml as Code Style in Eclipse.

How can I setup Android Studio / Intellij Idea to format code as in Eclipse?

UPDATE

I tried Eclipse Code Formatter plugin. It seems to work, but you cannot edit any setting at all. My team prefers 120 columns instead of 100.

I tried @CrossleSong answer too. It's a bit tricky, but more powerful. You can save this

https://android.googlesource.com/platform/development/+/android-4.2.2_r1.2/ide/intellij/codestyles/AndroidStyle.xml

as Android.xml and copy it to AndroidStudio/Intellij codestyles folder: for me is

~/Library/Preferences/AndroidStudioPreview/codestyles

Now you can select Android as Code Style in Android Studio Preferences.

解决方案

You can download the development repo from Android source. The development/ide/intellij folder includes code style, templates...

这篇关于Intellij Idea/Android Studio 中的 Android 代码风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆