简体   繁体   中英

Is it possible to keep my code style preferences permanent in Android Studio

To set your own code style preferences in Android Studio, the following steps would be followed:

File > Settings (Ctrl + Alt + S) > Editor > Code Style > Java.

or

File > Settings (Ctrl + Alt + S) > Editor > Code Style > Kotlin.

The scheme choices would be the following:

Andriod Studio 编辑器代码风格方案

However, when I do restart android studio these changes are not saved.

There have been times when I have had to Invalidate the Caches and Restart Android Studio. Would this have result in these preferences being lost? As my understanding of the clearing, the cache is code changes.

If you navigate to app >.idea > codeStyles folder you can see the codeStyleConfig and the Project code style, the codeStyleConfig lets the ide know which code style you have set whilst the Project file is an xml representation of the code style you defined in the settings.

I'm not sure why they are being cleared when restarting but you can add exceptions to these files in your gitignore file so that they can be committed, that way they should remain consistent even if you check the project out on another computer.

# IDEA/Android Studio ignore exceptions
!/.idea/codeStyles

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM