Shortcut keys are also called hotkeys. The combination of multiple keys enables quick operations, such as Ctrl+C and Ctrl+V, which are commonly used in Windows. Skilled use of shortcut keys greatly improves development efficiency and reduces errors. Android Studio also provides a number of shortcuts for developers to call by default. The default style of Android Studio shortcuts is recommended.



In fact, we do not need to recite it at once, just need to use the shortcut keys as far as possible in the development and print a shortcut key list next to the computer, often use and refer to, after a period of time will form a habit.

  1. Ctrl+G

At the same time, press Ctrl+G to pop up the quick location box. Enter the number of lines in the box and click OK to quickly switch to the corresponding number of lines, as shown in the picture below.

  1. Ctrl+E

At the same time, press Ctrl+E to display the list of recently opened files. You can quickly select the recently opened files

  1. Ctrl+/

Select a line and press Ctrl+/ to comment the line, as shown below.

  1. Ctrl+F

At the same time, press Ctrl+F shortcut key, the quick search bar within the class will pop up at the top of the editing page, you can quickly locate a word in the class, support associative search

Typing prote will highlight protected, and notice that there are three check boxes in the search bar. Selecting the first Match Case check box will be case-sensitive.

  1. Ctrl+R:

The Ctrl+F shortcut is often used with the Ctrl+R shortcut to quickly find and replace all

Use Ctrl+F to search for all protected items, then Ctrl+R to pop up the Replace bar. Enter the replaced word in the Replace bar input box and click Replace All to Replace all protected items in the class with public. However, use caution in real development to avoid introducing hidden problems.

  1. Ctrl+J

Press Ctrl and J at the same time to pop up the shortcut code box

For some common code encapsulation in Android Studio, directly selected can be quickly generated, very practical in development, here to print log and pop-up Toast as an example. First press Ctrl+J to pop up the shortcut code box as shown below, and then directly enter the “command” of the shortcut code logd.

Printing logs requires a TAG, which can be quickly generated by typing logt at the top of the class.

Again, type Ctrl+J to pop up the shortcut code box, and then directly type toast.

Press Enter or Ta once you have Toast

A Toast statement is quickly generated. Enter the information to be displayed in quotes. Is it very fast and convenient?

  1. Ctrl + F12:

In the case of a large number of methods in the class, press Ctrl and F12 keys at the same time to quickly view all methods in the class. When this box pops up, you can directly enter the method you want to search for fast matching.

\

  1. Ctrl+Alt+T

Select a piece of code and press Ctrl, Alt and T at the same time to pop up the “Wrap” pop-up box. Select the type of the package to wrap the selected code.

  1. Ctrl+Alt+L

Formats all code for the current class

  1. Ctrl+Alt+V

This shortcut allows quick declaration of a variable and local variable assignment

  1. Ctrl+Alt+H

Click on one of the methods and press this shortcut key to pop up the calling relationship of this method on the left bar. This shortcut key is very common in development.

  1. Ctrl+Alt+O

This shortcut can automatically guide packages or delete useless packages, press the shortcut key to automatically delete these useless packages

  1. Ctrl+Shift+/

Ctrl+Shift+/ comments a block of code. Press this shortcut again to uncomment that part of the code

This shortcut is often used in development to quickly search for information by keyword. Check the first box for case sensitivity. Click the TAB on the right to see a preview of the keyword

Ctrl+Shift+ plus/minus

If the method is folded, pressing Ctrl+Shift+ plus expands the method,

Conversely, if the method is expanded, pressing Ctrl+Shift+ minus at the same time will collapse the method

1. The Alt + Insert

Hold Alt and Insert at the same time to pop up quick code generation boxes, including constructors, getters/setters, toString, etc. Generating getter/setter methods is similar to generating constructors. Select the two properties and press the shortcut key to select getter and setter, as shown in the following figure. Selecting the OK key is the getter and setter methods that generate these two properties

  1. Alt + mouse

To edit multiple lines, press Alt and mouse to select multiple lines in Android Studio

3. Ctrl+ Left mouse button This shortcut key allows you to view the selected class or method with the mouse.