This article starts: http://prototypez.github.io/2016/04/19/about-10-things-you-probably-didn-t-know-you-could-do-in-android-studio/
Reprint please indicate the source
Android Studio is a tool that every Android developer uses every day, but even if you're an experienced developer, you've probably missed out on a lot of life-saving tricks, and this article might help you get a handle on some of them. I will not translate word, but in the most concise and understandable way to introduce to you, while providing the necessary annotations and extensions, so that you can quickly read after a quick grasp.
When you can't remember how a feature is used
If you are a windows/linux user, then please press, Ctrl + Shift + A if you are a MAC user, then press Command + Shift + A , in this universal input box you can enter the action you want to perform (of course, in English), the list will show the corresponding optional action and shortcut keys. Not only the operation, if you just want to change a setting, you can also use this function, for example, if you want to set the offline work, you can enter the Gradle input box, the offline corresponding results Toggle Offline Work , such as you need to open the Auto Import paste code function, then simply enter it in the input box Auto Import and select the corresponding item.
Modify shortcut keys
All shortcut keys are customizable in Android Studio. Please call the great Ctrl + Shift + A , input keymap , choose the Settings > Keymap option located, here can see all the fast key, generally not recommended in the original shortcut key program directly modify the shortcut, but instead of a copy of the existing scheme and then in the above change, in Keymaps the drop-down box to select an existing scheme (the default is Default), click on the right Copy , and then in the list need to modify the shortcut keys on the item right, select Add Keyboard Shortcut , and then you can set your favorite shortcut keys, if you set the shortcut keys and other keys are conflicting, will be red error message prompt.
Because of the number of shortcut keys in the list, we can also use the search box on the right to search, such as the need to modify the basic auto-completion of the shortcut keys we just enter Basic , we can find the corresponding item in the results.
What you need to know about auto-completion
In general, when using Android Studio, Automatic prompts will appear when you want to prompt, such as input Log. , will prompt a bunch of, for example, Log.d() Log.e Log.i() . However, if you are automatically prompted when the hand of the wrong choice, such as to choose the Log.d() results selected Log.e() , you will be .e() deleted, and then enter a, in . fact, encountered this need to re-call the automatic completion of the situation only need to use Ctrl + Alt + 空格 it.
In fact, there are two ways: first, the basic complement Ctrl + 空格 , but the Windows user is not happy, because this and windwos system switch Input Method shortcut key conflict, if you do not want to modify this shortcut, then use Ctrl + Alt + 空格 as an alternative, if you want to modify this fast key, Then you can use the method of the previous section to set a new shortcut, Keymaps Search in the interface Basic , and then select the filter results in the settings, and the Code Completion Basic other method is the intelligent completion Ctrl + Shift + 空格 , but the intelligent complement is far more than this function , when you invoke a method, you can use smart completion to associate a variable that conforms to the method parameter type in the current context.
Replace the current method or value with the Tab key after auto prompt
If we manually call out the auto-completion, the current position has a corresponding method or variable (such as originally called Obj's a method, and then we position the cursor to the position of the A method, call out the auto-completion, I hope the automatic completion of the B method instead of a method), this time if we select the completion of the project, press ENTER, Then the completion of the content will be inserted in front of the original content, this is not what we want, in fact, should not press ENTER, but instead Tab .
When you've finished writing a line of code
This is very common, when you finish writing a line of code, the cursor is not at the end of the current line, the more common is the right side of the cursor and N a right parenthesis, what will you do? You may use the arrow keys to move the cursor to the end of the line, and then manually enter one ; . In fact, there is a simpler solution, that is Ctrl + Shift + 回车 , this shortcut will help you automatically complete the current expression of the missing parts, including at the end of the input ; , it is worth mentioning that the shortcut key,,, the if else for while control loop is also valid.
Another situation where the cursor is not at the end of the line, but you want to be able to insert a blank row in the next line, Shift + 回车 can help you accomplish this task.
Three Tips for positioning
Using 4 arrow keys to position the cursor is the most familiar method, but it can be more convenient. While pressing the arrow keys, you can move a word one word at a time, press the UP Ctrl and down keys Alt , and you can move a node (method or field) by one node, and if you press the up and down keys Shift + Ctrl , you can swap positions between the current row and the upper and lower lines.
Automatically generated code templates based on suffixes
In the process of daily use of the editor, there are many formatting patterns, for example, and if-else for so on, using code templates to help us generate the desired code faster. For example, by entering a variable of a collection type and adding a suffix, the automatic hint prompts for a .fori loop to be generated by that collection type, and the expression of a for Boolean type with a .if suffix can also produce a statement that is conditional on that expression if .
In fact, the above two code templates are IntelliJ brought in, and Android Studio also offers many Android-related code templates, such as the generated Toast and Parcelable templates, and the way to view all available templates and custom templates is first Ctrl + Shift + A Call out the universal search box, enter Live templates , select located Settings Live Templates , and here you will see all the available code templates.
Tips for customizing object display at Debug time
When debugging code, we often need to look at the value of an object. In particular, custom objects, we often do not implement its toString method, then the object in the IDE is the value of ClassName:HashValue this look. We need to open this object to see the values of each member within it. There are better ways to do this without implementing toString the method. In the Debug Variable window, right-click the object you want to view, and select View as both to set how the object will appear in the debug state.
Summarize
Thank you for seeing this:)
Android Studio 10 Tips You're probably not aware of