Android Studio连续注释及代码折叠行为改变,3.1.1后如何恢复?
Hey there! I totally get how frustrating it is when code folding behavior shifts unexpectedly after an IDE update. Let’s walk through some targeted fixes to get back to your preferred folding logic—since you already tried resetting the general Code Folding settings without luck, these steps focus on more specific angles:
1. Check Language-Specific Code Folding Settings
Global settings can sometimes get overridden by language-specific configurations. Here’s what to check:
- Open
Preference > Editor > General > Code Folding - Expand the section for your project’s language (e.g., Java or Kotlin)
- Look for options like
Comment BlocksorContinuous Comments—ensure these are disabled, then restart Android Studio to apply changes.
2. Invalidate Caches & Restart
Android Studio’s cached data often causes weird, unaccounted-for glitches. This is a go-to fix for most IDE oddities:
- Go to
File > Invalidate Caches / Restart... - Select
Invalidate and Restartfrom the pop-up. Wait for the IDE to fully restart and reindex your project, then test the folding behavior again.
3. Revert to Old IDE Settings (If You Have a Backup)
If you exported your Android Studio settings before the 3.1.1 update:
- Go to
File > Import Settings - Select your old settings file (usually a
.jaror.ziparchive) - Make sure to check the
Code Foldingoption during import, then restart the IDE to roll back to your previous configuration.
4. Disable Third-Party Plugins
Some non-official plugins can quietly modify code folding logic. Let’s rule this out:
- Open
Preference > Plugins - Disable all non-Google plugins
- Restart Android Studio and test the folding. If it works, re-enable plugins one by one to identify which one was causing the conflict.
5. Manually Edit IDE Configuration Files (Advanced)
If none of the above works, you can tweak the underlying config files directly:
- Mac: Navigate to
~/Library/Preferences/AndroidStudio3.1/options/codeStyleSettings.xml - Windows: Go to
C:\Users\<Your Username>\.AndroidStudio3.1\config\options\codeStyleSettings.xml - Open the file in a text editor, find the
<component name="CodeStyleSettingsManager">section - Look for entries related to comment folding (e.g.,
<option name="COMMENT_BLOCKS" value="false"/>) and adjust them to match your desired behavior. Save the file, then restart Android Studio.
内容的提问来源于stack exchange,提问作者Tim Autin

