The original intention of the author to write this article is to list useful tips, tricks, shortcuts and reference resources for Android Studio that will improve your overall efficiency and operational performance. Obviously, there are many more optimizations, shortcuts, etc., but I kept this post short and limited it to 50. I hope you enjoy this post! Note: This article uses MacOS X to operate Android Studio as an example. The inconsistencies with Windows / Linux have been marked. Please pay attention to this. Visualization 1.Material Colors theme for Android Logcat. To change the Android Studio Logcat, you need to go to: Preferences → Editor → Colors & Fonts → Android Logcat, and then change the foreground color for each type of log. (Note that Perferences here is Settings on Windows/Linux.) My material colors are as follows:
2. To prevent Android Studio Logcat from crashing, the log of the current application should be cleared. To do this, you need to go to the Android Monitor panel and select Edit filter configuration from the drop-down list on the right. 3. Apply the correct code style to your IDE (IntelliJ / Android Studio). Click Preferences → Code Style → Java and select your code style in the Scheme drop-down list (or set a new one). There are 2 styles worth mentioning:
You can import the theme as shown in the gif below: 4. Use split screen to improve efficiency. To turn this feature on, you need to right-click on the tab on the Home screen and select Split Vertically/Horizontally. But to be as efficient as possible, we need to set a custom keyboard shortcut. To do this, go to Preferences → Keymap and find Split Vertically. Then open the context menu and click Add Keyboard Shortcut. In my case, for vertical split view, I added control + alt + v. As shown in the gif below. You can define shortcuts for horizontal split view as well. 5. Distraction Free Mode You can turn on distraction free mode by clicking View → Enter Distraction Free Mode. In distraction-free mode, the editor occupies the entire IntelliJ IDEA frame without any editor tabs and tool buttons, and the code is aligned in the center. [IntelliJ Idea View Mode] 6. Use live templates You can use the shortcut: cmd+j (Windows/Linux: ctrl+j). You can use many defined templates, like Toasts or if conditions. You can use your own custom template. Here is a reference article by Reto Meier. You can also refer to the IntelliJ IDEA documentation. Shortcuts and Useful Commands 1. The most common and useful command is Search for command: cmd + shift + a (Windows / Linux: ctrl + shift + a). When you want to close the current tab and don’t know how to do it, you can just type: close and you will get a correct shortcut/command. 2. Select from Recent Copy/Paste (Manage Clipboard): cmd + shift + v (Windows/Linux: ctrl + shift + v). By default, there are 5 copy/paste items. The depth of the clipboard stack is configured in the Limits section of the Editor page of the Settings dialog box. When the specified number is exceeded, the oldest entries are removed from the list. [Cut, copy, and paste in IntelliJ IDEA] 3. Enable the multi-cursor feature: control + g (Windows/Linux: alt + j). A detailed article about this feature is provided by Bartek Lipinski on Medium. Highly recommended! 4.Open a class: cmd + o (Windows/Linux: ctrl + n). 5.Open any file: cmd + shift + o (Windows/Linux: ctrl + shift + n). 6.Open symbol: cmd + option + o (Windows/Linux: alt + shift + n). 7.Go to implementation: cmd + option + b (Windows/Linux: ctrl + alt + b). Assuming you have an interface, by clicking on the name of the interface and then clicking on the Go to implementation shortcut, you will be redirected to the class that implements the interface. 8.Go to declaration: cmd + b (Windows/Linux: ctrl + b). It allows you to quickly inspect and go to the declaration of a class, method or variable. 9.Go to type declaration: control + shift + b (Windows/Linux: ctrl + shift + b). Suppose you define: Employee employee = new Employee("Michal"); When your caret is on employee and you click the shortcut, you will be redirected to the Employee class. 10.Go to super: cmd + u (Windows/Linux: ctrl + u). For example, you override some method. When you place the caret at the method name and click Go to super shortcut, you will be redirected to the parent method. 11.Move between tabs: cmd + shift + [ or cmd + shift + ] (Windows/Linux: alt + ← / →). 12.Move between Design / Text tabs in layout's view: control + shift + ← / → (Windows / Linux: alt + shift + ← / →). 13.Close a current tab: cmd + w (Windows/Linux: ctrl + shift + a). 14.Hide all windows: cmd + shift + F12 (Windows/Linux: ctrl + shift + F12). 15.Minimize Android Studio instance: cmd + m (Windows/Linux: ctrl + m). 16.Format your code: cmd + option + l (Windows/Linux: ctrl + alt + l). 17.Auto-indent lines: control + option + i (Windows/Linux: ctrl + alt + i). 18.Implement methods: control + i (Windows/Linux: ctrl + i). Suppose you implement an interface, then you can quickly import all the methods provided by the interface by just clicking this shortcut. 19.Smart code completion (filter the list of methods and variables by expected type): control + shift + space (Windows/Linux: ctrl + shift + space). 20.Find: cmd + f (Windows/Linux: ctrl + f). 21.Find and replace: cmd + r (Windows/Linux: ctrl + r). 22.Move hardcoded strings to resources: option + return (Windows/Linux: alt + enter). When using the caret on text, you have to use the shortcut. Check the gif below: If you use this shortcut globally, the IDE will perform a Project quick fix (showing the intention action and the quick fix). 23.Build and run: control + r (Windows/Linux: shift + F10). Plugins Key promoter - A plugin that helps you use your keyboard more often. String Manipulation - A plugin that provides actions for text manipulation (e.g. switching styles like camelCase, hyphen-lowercase etc, uppercase text and many more). Android Material Design Icon Generator - This plugin helps you set Material Design icons to your Android project. After installation, you can use the shortcut: cmd + shift + m to generate icons (default). ButterKnifeZelezny - A simple plugin that allows one-click creation of Butterknife view injections. IntelliJ/Android Studio Plugin for Android Parcelable boilerplate code generation - A plugin that generates Android Parcelable implementations based on the fields in the class. ADB Idea - A plugin to help and automate adb commands: uninstall, kill, start, restart, clear app and clear app data and restart it. Genymotion plugin - This plugin allows you to create and launch genymotion virtual devices from Android Studio. Android Methods Count - A plugin that parses your Android library's dependencies and displays the method count as a handy hint. Git Flow Integration - A plugin for introducing the Git Flow branching model. Builder plugin - A plugin (from Square) that generates a static nested Builder of a class. resource Philippe Breault: Secrets of Modern Android Studio Keyboard Shortcut Reference Reto Meier: 10 Things You Might Not Know You Can Do in Android Studio Hadi Hariri: Mouseless Development Philippe Breault: Android Studio Like a Boss Android Studio Expert (Android Development Summit 2015) Michael Evans: Android Studio Tips and Tricks Meet Android Studio Donn Felker: Android Studio - Tips and Tricks 《Debug your app with Android Studio》 《You should have a must-have plug-in——Reddit discussion》 |
<<: Android background killing series 2: ActivityManagerService and App on-site recovery mechanism
>>: Still using enumerations? I gave up on them a long time ago! (Android annotations explained)
High-quality content has three dimensions: the ab...
Google is shutting down its mobile shopping apps ...
As the Spring Festival approaches, with the optim...
In the use process of different products, users...
Nowadays, cars play an indispensable role in our ...
Expert in this article: Li Lin, PhD in Food Scien...
On July 2, at the main forum of the 26th Annual C...
The sci-fi movie "The Wandering Earth 2"...
As the Chinese home appliance industry collective...
I don’t know since when, the flat-chested girl ne...
Seed users generally have an open and adventurous...
Astronauts trapped in space?! The spacecraft carr...
Because we are currently in the midst of an epide...
One of them recently traveled to several province...
Produced by: Science Popularization China Author:...