LoginSignup
6
5

More than 5 years have passed since last update.

Googleが出してるAndroidStyle(コードフォーマット)を使えるようにする

Last updated at Posted at 2015-11-16

とりあえず結果

1.ターミナルで下記コマンド実行
curl -L https://gist.githubusercontent.com/futabooo/20513ee54c8afd05b4b8/raw/67670d97f060b5dbe8d590e8c9700855d8decd99/AndroidStyleCodeStyleInstall.sh | sh

2.AndroidStudio > Preferences > Code Style > Scheme でAndroidStyleを選択してOK
スクリーンショット 2015-11-16 22.33.00.png

詳細

OSクリーンインストールしたり、AndroidStudio再インストールしたりなんかでちょいちょい設定しなおしてるので、スクリプトを用意してみました。

#!/bin/bash
# Installs AndroidStyle IntelliJ configs into your user configs.
# Reference https://github.com/square/java-code-styles/blob/master/install.sh

echo "Installing AndroidStyle IntelliJ configs..."

for dirs in $HOME/Library/Preferences/IntelliJIdea*  \
         $HOME/Library/Preferences/IdeaIC*        \
         $HOME/Library/Preferences/AndroidStudio* \
         $HOME/.IntelliJIdea*/config              \
         $HOME/.IdeaIC*/config                    \
         $HOME/.AndroidStudio*/config
do
  if [ -d $dirs ]; then

    # Install codestyles
    mkdir -p $dirs/codestyles
    curl -L https://raw.githubusercontent.com/android/platform_development/master/ide/intellij/codestyles/AndroidStyle.xml \
    > $dirs/codestyles/AndroidStyle.xml

  fi
done

echo "Done."
echo ""
echo "Restart IntelliJ and/or AndroidStudio, go to preferences, and apply 'AndroidStyle' or '."
6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5