Android Studio:如何为只读文件添加个人注释?
Hey there! Great question—dealing with read-only files (like SDK sources or third-party library code) and wanting to jot down personal notes without modifying the original is a super common pain point. Luckily, Android Studio has several built-in tools that let you do this perfectly:
1. Bookmarks with Custom Descriptions
This is my go-to for quick, line-specific notes:
- Click the right margin next to the line number (or use the shortcut
F11for Windows/Linux,Fn+F11for Mac) to add a bookmark. - Right-click the tiny bookmark icon that appears, select Edit Description, and type in your personal notes.
- These notes are stored in Android Studio's local config—they never touch the original read-only file. You can view all bookmarks and their notes by pressing
Shift+F11to open the Bookmarks tool window, where you can even search through your notes.
2. External Annotations (For Library/SDK Files)
If you're working with read-only library code or Android SDK sources, this tool is tailored for you:
- Right-click the code you want to annotate, then go to Analyze > External Annotations > Add Annotation.
- Here you can add detailed comments, mark TODO items, or even add custom warnings/hints. All these annotations are saved in a separate local directory on your machine, so they don't alter the original read-only file at all.
3. Favorites with Notes
For marking entire code blocks or sections:
- Select the code you want to note, right-click it, and choose Add to Favorites.
- When naming your favorite, you can include your notes directly in the name, or right-click the favorite later to edit its details.
- Access all your favorites (and their notes) via the Favorites tool window, opened with
Alt+2(Windows/Linux) orCmd+2(Mac).
All these methods keep your personal documentation completely isolated from the original file, so you never have to worry about messing with read-only permissions or breaking source code. Your notes will stick around between IDE sessions as long as you don't reset your Android Studio settings.
内容的提问来源于stack exchange,提问作者Lore

