GreenOwl
GreenOwl

Reputation: 765

How to import .XML code style into Android Studio

I'm using Android Studio on OS X, and want to import intellij-java-google-style.xml for my code format.

But I can't find import at Preferences -> Project Settings -> Code Style -> Manage only Save as, Delete, Copy to project, and Close there.

Upvotes: 46

Views: 37691

Answers (6)

prodaea
prodaea

Reputation: 1770

In the latest Android Studio (as of this edit, 4.1.1) you can go to Preferences -> Editor -> Code Style -> Scheme -> Settings Icon (Gear) -> Import Scheme... and import the xml there.

Upvotes: 14

Marco RS
Marco RS

Reputation: 8245

If you are on Android Studio Preview you will need to copy your style xml file to:

~/Library/Preferences/AndroidStudioPreviewX.X/codestyles

where X.X is your Preview version ie. 1.4

Upvotes: 8

breadsheng
breadsheng

Reputation: 103

Also, for those who use Android Studio on windows. Copy your xml file to $USER_SPACE$\.AndroidStudio1.X\config\codeStyles. If you don't have the codeStyles folder, just create one. And then you will see it in Settings->Editor->Code Style->Scheme.

Upvotes: 7

blackwabi
blackwabi

Reputation: 161

I am using Android Studio 1.2 on Ubuntu 12.04 and in my case I have an .AndroidStudio1.2 folder in my home directory. In this folder there is a config folder. What I did was the following:

  1. I created a new folder called codestyles in the config folder.
  2. copied my style xml (in my case named AndroidStyle.xml) into the codestyles folder (.AndroidStudio1.2/config/codestyles/AndroidStyle.xml)
  3. Went into File>Settings>Editor>Code Style
  4. Chose the AndroidStyle among the listed Schemas.

NOTE: Android Studio does not give you an option to import the xml file. And before you add the file to the codestyles folder there is NO indication that you can change the Schema to your own in any way. But after you have added the file the added schema will be shown among the other schemas.

NOTE 2: In other Operating systems this folder is located elsewhere. For more info on configuration folders see here: http://tools.android.com/tech-docs/configuration

Upvotes: 13

passerby4j
passerby4j

Reputation: 319

Copy intellij-java-google-style.xml into the directory $HOME/Library/Preferences/IdeaIC14/codestyles/.

Upvotes: 31

sshturma
sshturma

Reputation: 1151

Here are steps I used to import my coding style for a project.

  1. Place codingStyle.xml to .idea folder under your project.
  2. In Android Studio select Project for coding style scheme, click OK.
  3. Place original codingStyle.xml to .idea folder again (Android Studio most likely had overwritten with default settings your codingStyle.xml when you click OK on step 2)
  4. Restart Android Sturdio.

Upvotes: 5

Related Questions