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.
Apply a predefined code stylePress Ctrl+Alt+S to open the IDE settings and select Editor | Code Style. To configure a scheme for new projects, go to File | New Projects Setup | Settings/Preferences for New Projects | Editor | Code Style. Select the language for which you want to configure the code style.
In the editor, select a code fragment you want to reformat. Before reformatting, you can take a look at the code style settings that are applied to the selected code: press Alt+Enter and click Adjust code style settings. From the main menu, select Code | Reformat Code or press Ctrl+Alt+L .
Sometimes code formatting can get out of sync, but there's an easy fix in IntelliJ IDEA. You can use ⌘⌥L (macOS), or Ctrl+Alt+L (Windows/Linux) to reformat a selection of code according to your reformat settings.
Android Studio and the Android plugin for IntelliJ IDEA are built from the same code, and all of the changes in Android Studio are, and will continue to be, available in IntelliJ IDEA releases.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With