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
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...
Instructions to use Eclipse XML formatter in Android Studio :
I hope I wrote instructions clear. Let me know in case you didn't understand.
您可以使用IntelliJ IDEA / Android Studio的第三方Eclipse Code Formatter插件。
For Android Studio 1.2.2
and above:
What didn't work for me:
Thanks for the question. There are good answers and hints here but for my case where I updated to Android Studio 1.2.2, it didn't work right out of the box. Some answers and blogs suggested that after downloading the xml
file,
xml
file to ~/Library/Preferences/AndroidStudio/codestyles
. AndroidStudio
Go to Android Studio -> Preferences -> Code Style -> Java
and from Scheme
dropdown select the scheme name and save.
However when I put the xml file inside ~/Library/Preferences/AndroidStudio/codestyles/
folder it didn't show my scheme name in the Scheme
dropdown to select from.
What worked for me:
After I updated Android Studio to latest version, under ~/Library/Preferences/
in mac, I had two folders: AndroidStudio
and AndroidStudio1.2
. For importing the AndroidStyle.xml code style file in the updated Android studio, I had to create a folder named codestyles
inside ~/Library/Preferences/AndroidStudio1.2/
folder, since none existed. Then I saved the xml
file in there and followed the above procedure . Just saving the file solely in .../AndroidStudio/codestyles
folder didn't work for me.
Hope it helps someone some day.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.