计算机操作系统： Windows 7
如果关闭了提示对话框，可在 Help | Tip of the Day 打开。
Welcome to Android Studio 2.2 You can quickly get familiar with the main features of the IDE by reading these tips.
You may try out the features described in the tips while this dialog stays open on the screen.
If you close the dialog, you can always get back to it from the
Help | Tip of the Daymain menu item.
Ctrl + N
Ctrl + N 搜索
To open any class in the editor quickly, press
Ctrl+N (Navigate | Class)and start typing the name of the class. Choose the class from a drop-down list that appears.
You can open any file in your project in a similar way by using
Ctrl+Shift+N (Navigate | File)
The Code Completion feature lets you quickly complete different kinds of tatements in the code.
For example, start typing a class name and press
Ctrl+空格to complete it. When multiple choices are available, they are shown in the lookup list.
The CodeCompletion feature can suggest a name for a variable when you declare it. For example, start typing
You can customize name prefixes for local variables, parameters, instance and static fields in
File | Settings | Code Style.
When using basic code completion (
Ctrl+空格), type any characters that exist anywhere in an identifier.
Use Basic Completion (
Ctrl+空格) for completing words in text and comments in files of many different types.
All the words from the current file that start with the typed prefix will appear in the lookup list.
Use Basic Completion (
Ctrl+空格) within HTML, CSS and other files, for
completing image file names.
You can use Basic Completion (
You can use Basic Completion (
Ctrl+空格) within Java String literals and in other file types, for completing
When using basic code completion (
Ctrl+空格), you don't need to type upper-case letters in CamelHump names. It is enough to type the initial letters of the camel names in lower case, and they will be smartly recognized.
You can quickly find all places where a particular class, method or variable is used in the whole project by positioning the caret at the symbol's name or at its usage in code and pressing
Alt+F7 (Edit | Find | Find Usagesin the popup menu).
You can bring forward the list of all usages of a class, method or variable across the whole project, and quickly jump to the selected usage. To do that, place the caret at the symbol's name or at its usage in code and press
Edit | Find | Show Usagesin the main menu), scroll the list and click the desired usage.
To quickly see the documentation for a class or method at caret, press
Ctrl+Q (View | Quick Documentation).
To navigate to the declaration of a class, method or variable used somewhere in the code, position the caret at the usage and press
Ctrl+B (Navigate | Declaration). You can also click the mouse on usages with the
Ctrlkey pressed to jump to declarations.
You can quickly navigate in the currently edited file with
Ctrl+F12 (Navigate | File Structure). It shows the list of members of the
current class. Select an element you want to navigate to and press the
Enterkey or the
F4key. To easily locate an item in the list, just start typing its name.
You can easily rename your classes, methods and variables with automatic correction of all places where they are used.
To try it, place the caret at the symbol you want to rename, and press
Shift+F6 (Refactor | Rename). Type the new name in the popup window that appears, or select one of the suggested names, and press
You may easily override methods of the base class by pressing
Ctrl+O (Code | Override Methods).
To implement methods of the interfaces that the current class implements (or of the abstract base class), use
Ctrl+I (Code | Implement methods).
The SmartType code completion greatly helps to find methods and variables that are suitable in the current context, by analyzing the expected type of the whole expression. So doing, Android Studio pinpoints the top five most suitable results and highlights them on the green background. For example, type
The SmartType completion also works after the return keyword, in an assignment, in an argument list of a method call and other places.
The SmartType code completion may be used after the
newkeyword, to instantiate an object of the expected type. For example, type
When you need to cast an expression value to the required type the SmartType code completion will help you. For example, type
String s = (
<caret is here>
Ctrl+Shift+空格to see what happens.
When using Code Completion, you can accept the currently highlighted selection in the popup list with
Unlike accepting with the
Enterkey, the selected name will overwrite the rest of the name to the right of the caret. This can be especially useful for replacing one method or variable name with another.
Alt + Click关闭其他选项卡
Did you know that you can close tabs in the editor and the tool windows of Android Studio without actually using the context menu commands? It is enough to point with your mouse cursor to a tab to be closed, and click the middle mouse button, or just use the
生成构造函数、Getter and Setter、toString()等方法。
Alt+Insert (Code | Generate)in the editor, you can easily generate getter and setter methods for any fields of your class.
如图所示，可以快速切换到不同的视图：项目视图(Project, Packages, Android)、文件结构、在Exporler中显示等等。
To quickly select the currently edited element (class, file, method or field) in any view (
Structureview or other), press
speed search in the tree views
The speed search is available in all the tree views: just start typing and you'll quickly locate the necessary item.
Focus of the Editor
Esckey in any tool window moves the focus to the editor.
Shift+Escmoves the focus to the editor and also hides the current (or last active) tool window.
F12key moves the focus from the editor to the last focused tool window.
try / catch、
When you want to catch exceptions thrown by some code fragment, select it in the editor, press
Code | Surround With) and choose
try / catch. The catch blocks for all the exceptions thrown inside the block will be generated automatically.
You can customize the bodies of the generated catch blocks on the
File | Settings | File and Code Templates.
Use other items in the list to surround with other constructs.
To navigate to the implementation(s) of an abstract method, position the caret at its usage or its name in the declaration and press
Ctrl+W，方法表达式 > 该行 > 包含块 > 整个方法 > 整个类块
Ctrl+W(extend selection) in the editor selects the word at the caret and then selects expanding areas of the source code. For example, it may select a method name, then the expression that calls this method, then the whole statement, then the containing block, etc. You can also select the word at the caret and the expanding areas of the source code by double-clicking the target areas in the editor.
The Extract Variable refactoring helps you simplify complicated statements in your code. For example, in the code fragment below, you can select an expression in the code:
Refactor | Extract | Variable...). This will result in the following:
You can use the Extract Variable refactoring even on incomplete statements. Just press
Ctrl+Alt+V, and choose the desired expression:
comment or uncomment
You can comment or uncomment lines and blocks of code using
Ctrl+斜杠comments or uncomments the current line or selected block with single line comments (
Ctrl+Shift+斜杠encloses the selected block in a block comment (
To uncomment a commented block press
Ctrl+Shift+斜杠anywhere inside it.
To open your browser with documentation for the element at the editor's caret, press
View | External Documentation).
You must have the path to your browser set in the
File | Settings | Web Browsersoptions and paths to documentation files added to your project (
File | Project Structure...) to use this feature.
Ctrl+Din the editor duplicates the selected block or the current line when no block is selected.
Try Live Templates
使用Live Templates, 常用的比如 Toast，可以在设置中自定义常用模板。
Try Live Templates
Live Templates allow you to generate many typical code constructs in seconds! For example, type
in a method and press the Tab key to see what happens.
Tabkey to move between the template fields. See
File | Settings | Live Templatesfor more details.
If the cursor is between the parentheses of a method call, pressing
Ctrl+Pbrings up a list of valid parameters.
Navigate | Last Edit Location) brings you back to the last place where you made changes in the code.
Ctrl+Shift+Backspacea few times moves you deeper into your changes history.
Edit | Find | Highlight Usages in File) to quickly highlight usages of some variable in the current file.
Shift+F3keys to navigate through highlighted usages.
Escto remove highlighting.
view all methods of the implemented interfaces in a class
You can view all methods of the implemented interfaces in a class, if you place the caret at the implements keyword in the class declaration, press
Ctrl+Shift+F7, and select the desired interface from the list:
view all statements within the method where certain exceptions can be caught
Ctrl + Shift + F7并从列表中选择所需的异常类，该功能对
You can view all statements within the method where certain exceptions can be caught. Just place the caret at the
throwskeyword in a method declaration, press
Ctrl+Shift+F7and select the desired exception class from the list. This will also work for
Reformat Code / Optimize Imports
Code | Reformat Codeto reformat code according to your code style preferences (
File | Settings | Code Style).
You can also use
Code | Optimize Importsto automatically optimize imports (remove unused imports, etc.). To access the corresponding settings, use
File | Settings | Code Style | Imports.
Local History | Show History
Local History | Show History可以查看本地历史，并且可浏览不同的版本文件，查看差异并回滚到任何以前的版本。
To see your local history of changes in a file, invoke
Local History | Show Historyfrom the context menu. You can navigate through different file versions, see the differences and roll back to any previous version.
Use the same context menu item to see the history of changes on a directory. You will never lose any code with this feature!
View | Context Info) to see the declaration of the current method without the need to scroll to it.
View | Recent Files) brings a popup list of the recently visited files. Choose the desired file and press
Enterto open it.
Besides recent files, you can bring up results of the usage searches you have performed recently. To do that, use the same
Ctrl+Eshortcut with the Find tool window having the focus, and select the desired find usages result from the
Recent Find Usagespopup.
Go to high priority problems only
search operation results是什么不了解。
Shift+F2keys to jump between highlighted syntax errors.
Ctrl+Alt+向下箭头shortcuts to jump between compiler error messages or search operation results.
To skip warnings right click on the validation side bar / marker bar and choose
Go to high priority problems only.
Ctrl+J / valid Live Template abbreviation
Ctrl+Jto complete any valid Live Template abbreviation if you don't remember it. For example, type it and press Ctrl+J to see what happens.
Show method separators
To show separator lines between methods in the editor, open the editor settings and select the Show method separators check box in the
move between methods in the editor
Alt+向下箭头keys to quickly move between methods in the editor.
Ctrl+Shift+J / joins two lines into one
Ctrl+Shift+Jshortcut joins two lines into one and removes unnecessary space to match your code style.
Refactor | Copy
Refactor | Copyto create a class which is a copy of the selected class. This can be useful, for example, when you need to create a class which has much in common with some existing class and it's not feasible to put the shared functionality in a common superclass.
Ctrl+Shift+Vshortcut to choose and insert recent clipboard contents into the text.
To see the inheritance hierarchy for a selected class, press
Navigate | Type Hierarchy). You can also invoke the hierarchy view right from the editor to see the hierarchy for the currently edited class.
Right-clicking on a breakpoint marker (on the bar to the left from the text) invokes the speedmenu where you can quickly enable/disable the breakpoint or adjust its properties.
evaluate the value of any expression
To easily evaluate the value of any expression while debugging the program, select its text in the editor (you may press a
Ctrl+Wa few times to efficiently perform this operation) and press
To quickly evaluate the value of any expression while debugging the program, hold
Altand click this expression to see its value and calculate it, call a method, etc.
The shortcuts such as
View | Quick Documentation),
View | Parameter Info),
Navigate | Declaration) and others can be used not only in the editor but in the code completion popup list as well.
accept the currently highlighted selection in the popup list
When using Code Completion, you can accept the currently highlighted selection in the popup list with the period character (
.), comma (
,), semicolon (
;), space and other characters.
The selected name is automatically entered in the editor followed by the entered character.
short description of main menu
To help you learn the purpose of each item in the main menu, its short description is shown in the status bar at the bottom of the application frame when you position the mouse pointer over this item.
For the pattern search in the
Go to Class,
Go to Symboland
Go to Filepop-up frames, use
*and space symbols.
*stands for any symbol.
Space at the end means the end of a pattern, and the preceding string will be considered not just a prefix but a whole pattern. The list of the suggested names will be reduced accordingly.
Move refactoring on an inner class that is declared static
When you invoke the Move refactoring (
F6) on an inner class that is declared
static, you are provided with an option to either make it a top-level class, or move it to another class.
To open any particular method or field in the editor quickly, press
Navigate | Symbol) and start typing its name. Choose symbol from the drop-down list that appears.
Alt+Shift+Cto quickly review your recent changes to the project.
Ant property or target
You can start referring to an Ant property or target even if it is not defined yet. An intention action feature will suggest you to automatically create the necessary tag, without the need for you to leave your current editing location.
Quick Switch Scheme
With a single keystroke, you can apply another code style/coloring scheme or keymap right from the editor. Just press
View | Quick Switch Scheme), to specify the scheme you want to change.
Ctrl + Shift + Enter完成当前语句，如
Ctrl+Shift+Enterto complete a current statement such as
return(or a method call) into a syntactically correct construct (e.g. add curly braces).
When in the
Go to Class,
Go to Symbol, or
Go to Filepopup, you can ease the search by filtering the lookup list with the help of the "camel words" prefixes.
View | Quick Definition), to quickly review definition or content of the symbol at caret, without the need to open it in a new editor tab.
Edit | Copy Referenceaction can be used to insert a reference to a field/method/class/file into the current position in the editor. For example, go to the
java.util.CollectionsJDK class, place the cursor within the
EMPTY-MAPfield and press
Then return to your source code and press
You can also copy references in the
GotoClass/GotoSymbol/GotoFiledialogs. Just press
Ctrl+Con any element in the lookup list.
Move Statement Up/Down
Code | Move Statement Up/Downaction is useful for reorganizing the code lines in your file, e.g., for bringing a variable declaration closer to variable usage.
Select a code fragment and press
The following pictures show an initial location of a code fragment, and the results of moving the selected fragment up and down.
When nothing is selected in the editor, the line at the cursor will be moved.
Alt+Shift+F10you can access the Run/Debug dropdown on the main toolbar, without the need to use your mouse.
Quick Definition Viewer
Quick Definition Viewer(
Ctrl+Shift+I) can also be used for items in lookup lists that appear on code completion and class/file/symbol navigaton commands.
Show Applied Styles For Tag
Show Applied Styles For Tag 在
Tool Window 即显示应用的样式列表
You can quickly review all styles currently applied to an HTML tag, by right-clicking the tag name and selecting
Show Applied Styles For Tagfrom the context menu:
view the image referenced at caret
You can quickly view the image referenced at caret by using the Quick Definition (
Ctrl+Shift+I). The underlying image will be opened in a popup instead of a separate editor tab.
Refactor | Rename
It is possible to rename CSS selectors directly from HTML. Position the caret at the selector to be renamed and press
Refactor | Rename).
shortcut to show the navigation bar
Alt + Home显示导航栏，使用箭头键来定位到文件或文件夹。
Navigation bar is a quick alternative to the
Alt+Homekeyboard shortcut to show the navigation bar, and arrow keys to locate the necessary files or folders.
shortcut to show or hide this tool window
Alt + 9显示或隐藏此工具窗口。
Changestool window shows all deleted, modified, and unversioned files in a single view. Use
Alt+9keyboard shortcut to show or hide this tool window.
Changestool window you can perform all the necessary version control actions:
put resources under version control,
examine differencesand more.
If you notice that Android Studio works slowly, consider the possibility to reduce the number of folders under antivirus protection.
Each antivirus check in your project consumes resources. You can significantly improve the performance, if you exclude certain folders from the antivirus protection.
quickly open a Maven project
You can quickly open a Maven project by selecting a
pom.xmlfile in the
File | Opendialog. The corresponding Maven project is imported with default settings, without launching the wizard.
If you don't want to commit some of your changes to the repository, you can set them aside for a while, by moving to a separate changelist, or by putting them to a shelf. Select such file in the
Localtab of the
Changestool window, and on the context menu choose
Move to Another Changelist, or
quickly open an Eclipse project
You can quickly open an Eclipse project by selecting a
.projectfile in the
File | Opendialog. The corresponding Eclipse project is imported with default settings, without launching the wizard.
quickly find a menu command or toolbar action
Ctrl + Shift + A（主菜单上的
Help | Find Action”），然后开始输入操作名称，而不需要查看菜单。
To quickly find a menu command or toolbar action, you do not need to look through the menus. Just press
Help | Find Actionon the main menu) and start typing the name of the action. Choose the desired action from the suggestion list.
quickly find and run an inspection
inspection和 lint 是
Settings | Editor | Inspection查看，也可以配置单项的严重程度和作用域。
To quickly find and run an inspection, press
Ctrl+Alt+Shift+Iand start typing the name of the inspection or its group. Choose the desired inspection from the suggestion list and then specify the desired scope.
quickly find a setting
Ctrl + Alt + S 打开设置，可在搜索框输入搜索。
You can quickly find a setting you need in the
Settings/Preferencesdialog, without browsing through the numerous options. Just type some characters that, in your opinion, exist in the option description, and the list of settings will reduce to the matching ones. Select the desired entry, and see the setting that contains the entered characters highlighted:
searching for a text string in a file
When searching for a text string in a file, use recent history: with the search pane already open, click the down arrow to show the list of recent entries.
finding text in the current file
Ctrl + F）时，不需要输入整个搜索字符串：可以使用
When you are finding text in the current file (
Ctrl+F), you don't need to type the whole search string: Basic Code Completion is available in the search field. Start typing, press
Ctrl+空格, and select the desired string from the suggestion list.
To view all exit points of a method
To view all exit points of a method, place the caret at one of them, e.g. the return statement, and press
invoke a quick fix or intention action
When you press
Alt+Enterto invoke a quick fix or intention action, press the right arrow key to reveal the list of additional options. Depending on the context, you can choose to disable inspection, fix all problems, change inspection profile, etc.
navigate to any part of the file path
Ctrl+Click (Windows) or
Ctrl+Click(on Windows) or
Cmd+Click(on MacOS) a tab in the editor to navigate to any part of the file path. Select the necessary element in the drop-down, and the corresponding file path opens in an external browser (e.g., in the Explorer, if your OS is Windows).
Settings | Version Control | Issue Navigation中定义。
Android Studio lets you jump from your check-in comment to an issue in your task tracker.
All you have to do is to define issue navigation patterns in the
Settings | Version Control | Issue Navigationdialog:
When you commit a changelist, and type the check-in comment, make sure it matches one of your issue navigation patterns. Later, when you browse through the changelists in the repository, such comments turn into hyperlinks:
Clicking a hyperlink brings you directly to an issue in your task tracker
choose the desired color from the color picker
Android Studio simplifies your work with colors in CSS files. The
colorproperties have the icons of the corresponding color in the left gutter area of the editor.
Click color icons to choose the desired color from the color picker.
Android Studio 帮助直接从类声明创建
Alt + Enter，然后从建议列表中选择
Android Studio helps create test cases directly from class declaration. With the caret at the class name in the editor, press
Alt+Enter, and choose
Create Testfrom the suggestion list:
easily make column selection
同时选择多行，如 Sublime Text
You can easily make column selection by dragging your mouse pointer while keeping the
Appearance & Behavior | File Colors设置(自定义颜色)，也可以
You don't need to guess which
index.htmlfile you are looking at...
Make the editor tabs and lines in navigation lists stand out using the
File Colorspage of the project settings.
whole line at caret is copied
Ctrl + C会复制光标所在的整行内容
If nothing is selected in the editor, and you press Ctrl+C, then the whole line at caret is copied to the clipboard.
Move to Another Changelist
Move to Another Changelist选择即可。
You can move any file to a changelist of your choice. To do that, just choose
Move to Another Changeliston the file context menu in the Changes tool window:
Alt + Enter查看可用操作的列表。
Keep your source code typo-free with the help of the built-in Spellchecker.
All texts, including comments, textual strings and literals, are inspected against the pre-defined dictionaries. All typos are highlighted, which leaves you with the task of choosing the correct word, accepting the current spelling, or disabling inspection.
Alt+Enterto see the list of available actions.
Editor | Spelling 中通过
If you lack words in the pre-defined dictionaries, you can create your own ones. A custom dictionary is a mere textual file with a
.dicextension, with each word starting on a new line.
All you have to do is to point to the directories where your dictionaries are stored, in the
VCS | VCS Operations Popup即弹出VCS命令选择列表。
All your most indispensable VCS commands are just one-click away...
VCS | VCS Operations Popupon the main menu, and get a popup with the VCS commands that are relevant to the current context:
Use the Switcher
Ctrl + Tab）在打开的文件和工具窗口之间切换。
Shift + Tab；
Use the Switcher (
Ctrl+Tab) to switch between open files and tool windows. Keeping
Ctrlpressed, use the
Altfor navigation; use
BackSpaceto close editor tab or hide a tool window.
open an external file for editing
You can easily open an external file for editing, if you just drag it from the Explorer or Finder to the editor.
closing all tabs in the editor
There are two ways of closing all tabs in the editor, except the current one:
First, right-click the editor tab, and choose Close Others on the context menu.
Second, keeping the Alt key pressed, click on the editor tab.
jump directly to any deeply buried file
Ctrl + Shift + N，并只输入几个字符的封闭目录和文件名。
You can jump directly to any deeply buried file, if you press Ctrl+Shift+N, and type just a couple of characters of the enclosing directories and file names:
Use either a slash or a backslash as a delimiter.
open any class or file in the editor
To open any class or file in the editor at the desired line, press
Navigate | File), start typing the name, and choose the one from the suggestion list. Then type the colon (
:) and a line number.
The selected file will open with the caret at the specified line.
Show Diff of Version control
Version control annotations show the latest changes of each line in one click.
Just right-click an annotation and use the
Show Diffcommand in the context menu.
compare two directories
To compare two directories, select one or both of them in the
Projectview and press
hide/show the tool windows bars
If you need more workspace, you can hide the tool windows bars: click in the lower left corner.
If necessary, you can show the tool window buttons just for a moment. To do that, press the key
Alt(for Windows/*nix) or
Command(for Mac) twice and keep it down. While the key is pressed, the tool window buttons are visible.
exclude any file from your project
You can exclude any file from your project. As a result, such a file will be ignored by indexing, inspection and code completion.
Projecttool window, select the file you want to ignore, and choose
Mark as plain textin its context menu.
If necessary, you can always return the file to its original type using the
Mark as <file type>context menu command.
Ctrl + K 快速调用
The keyboard shortcut
Ctrl+Kenables you to quickly invoke the
This dialog shows all modifications in project, gives summary information of file status and suggests improvements before check-in.
toggle between find and replace
It is very easy to toggle between find and replace functionality.
When you perform search and replace in a file, pressing
Ctrl+Fshows the search pane. Pressing
Ctrl+Radds field, where you can type the replace string.
While in the
Find in Pathdialog, you can switch to replace by pressing
Ctrl+Shift+R. Same way, press
Ctrl+Shift+Fto hide the
Replace withfield, and switch to mere search.
If you are working on a large project, with numerous TODO items, filter them by scopes.
Use the Scope-Based tab in the TODO tool window to show only those items that pertain to the scope of interest.
TODO tool window
TODOtool window lets you preview each of the encountered TODO items - just click the preview button on the toolbar.
method signature quick fix
If a method signature has been changed, Android Studio highlights the tags that ran out of sync with the documentation comment and suggests a quick fix:
Remove the tasks
When working with a lengthy list of tasks, you don't need to delete them one by one. Select several tasks, using
Control/Commandkeys, click the right arrow, and then click
If there are too many run/debug configurations of the same type, you can group them into folders, and thus distinguish them visually.
Settings | Live Templates页面中可以快速搜索模板。
Live Templatessettings, use speed search to find templates with certain text in the template abbreviation, body or description.
Start typing the desired text, and the list of available templates will shrink to show matching templates only:
You can avoid escaping backslashes in your regular expressions. Start typing a regular expression, then press
Edit RegExp. The regular expression opens in a separate tab in the editor, where you can type backslashes as is.
All changes are synchronized with the original regular expression, and escapes are presented automatically. When ready, just press
Escto close the regular expression editor.
Editor | Emmet
Speed up HTML, XML or CSS development with
Enable this framework in the corresponding page of the
Editor | Emmetnode (
All escaped characters in the
*.propertiesfiles in the format
\uXXXX, are displayed in the resource bundle editor as un-escaped unicode literals.
Vice versa, if a non-ASCII character is entered in the resource bundle editor, it is reflected in the underlying
*.propertiesfile as a corresponding escaped character in the format
For example, if the
*.propertiesfile contains a property value
then the resource bundle editor will show
To view which line separators style is used in the current file, look at the Status Bar:
To change the current line ending style, just click the spinner.
You do not need to open a file in the editor to change its line separator style. Use the
Project tool windowinstead: select one or more files, or folders, point to
File | Line Separatorson the main menu, and then choose the desired line ending style.
For a directory, new line separator applies recursively.
list of refactorings
If you place the caret at certain symbol and press
Ctrl+Alt+Shift+T, you will see the list of refactorings applicable to the current context.
You want your bookmarks and breakpoints to be always at hand, so that you can easily navigate through them?
They are visible in the
Favoritestool window, which you can dock or float as required:
drop file onto the Favorites tool window
You can drag an external file from the Explorer or Finder, and drop it onto the Favorites tool window.
Tune the Android Studio tool windows layout
Tune the Android Studio tool windows layout to make better use of your screen.
Toggle between the vertical and side-by-side placement of the tool windows by Ctrl+Click/Cmd+Click on the splitter:
You don't need to leave Android Studio to work with your favorite shell. Just click the Terminal tool window button, and enjoy using the embedded local terminal.
define your favorite shell
For the embedded local terminal, you can define your favorite shell, default tab name, and other settings. Choose
File | Settingson the main menu, and then open the page
Enable the horizontal scrolling
Enable the horizontal scrolling with the mouse wheel by holding the Shift key.
double pressing the Shift key
Android Studio allows you to search through the classes, files, tool windows, actions, settings, and symbols of your project by double pressing the
When using autopopup Code Completion, you can select the first item using
Ctrl+句点. The selected name is automatically entered in the editor followed by dot.
When an autopopup completion is active,
Ctrl+向上箭头will close it and move the caret down or up in the editor.
"camel words" ease the search
When in the Code Completion lookup, you can ease the search by filtering the list with the help of the "camel words" prefixes.
suggest to get an element from this array
Pressing the same shortcut after you have invoked Smart-type Completion when there's an array of expected type in context will suggest to get an element from this array.
suggest to convert searched for arrays using Arrays.asList() call
Pressing the same shortcut after you have invoked Smart-type Completion when a collection type is expected will search for arrays with same component type and suggest to convert them using Arrays.asList() call.
search for chained expressions
Pressing the same shortcut after you have invoked Smart-type Completion will search for chained expressions which have expected type.
accept the currently highlighted selection in the popup list
When using Code Completion, you can accept the currently highlighted selection in the popup list with the
Ctrl+Shift+Enter, Android Studio will not just insert the selected string, but also will do its best to turn current code construct into syntactically correct one (balance parentheses, add missing braces and semicolons, etc.)
accept the currently highlighted selection in the popup list In Java
When using Code Completion in Java, you can accept the currently highlighted selection in the popup list with the exclamation sign (!) character. It will be inserted before the boolean method or variable you were completing, thus negating the whole expression.
After pressing '!':
method to be imported statically
To quickly complete a method call of a static method located anywhere in your project, libraries or JDK, enter a prefix and press Ctrl+空格 twice. You'll see all the matching methods. If you want the method you chose to be imported statically, press Alt+Enter and see what happens:
view all accessible classes
When you invoked Basic Completion (Ctrl+空格) in Java and didn't find your desired class in the list, it means that it's not yet imported in current file. Pressing Ctrl+空格 once more to view all accessible classes.
suggest to convert Smart-type Completion result using toArray() call
Pressing the same shortcut after you have invoked Smart-type Completion when an array type is expected will search for collections with same component type and suggest to convert them using toArray() call.
sorting completion variants by relevance or alphabetically
You can switch between sorting completion variants by relevance or alphabetically by using an icon at the bottom right:
Postfix code completion
Postfix code completion is applied "from right to left" and lets you avoid backward caret jumps when coding. After the code fragment that you want to change, type a dot (
.), optionally press
Ctrl+Jand select the desired option.
Scratch files allows you experiment and prototype right in the editor, without creating any project files.
To create a scratch file, press Ctrl+Alt+Shift+Insert, and then select its language.
changed a live template
If you've changed a live template, it becomes blue. If you want to return to the original text, right-click such a blue template, and choose
Restore defaultson the context menu.
Add several cursors to your editor
Add several cursors to your editor. To do that, press Ctrl twice and hold the key, and then press the arrow keys.
On Mac use Alt instead of Ctrl.
Clone the cursor
Clone the cursor strictly upwards or downwards. To do that, press
Clone caret, and then choose the desired action.
view quick documentation when choosing a live template
When choosing a live template from a suggestion list, press Ctrl+Q to view quick documentation - to be sure you make a right choice:
launch the embedded local terminal using keyboard only
Android Studio makes it possible to launch the embedded local terminal using keyboard only. Press Alt+F12, and see the terminal running.
Make your printoutsnice and informative with the help of keywords
Make your printouts (File | Print) nice and informative with the help of keywords.
For example, use $DATE$ and $TIME$ to specify the exact date and time of the printout.
show documentation for a lookup item
When in a Code Completion lookup, press
Ctrl+Qto show documentation for a lookup item, including class constructors.
So doing, if a class has more than one constructor, the links are shown:
Following a link shows documentation for the selected constructor.
Have you noticed the buttons >><< marking differences in the Differences viewer?
You can simply apply differences between panes, by clicking one of these chevron buttons.
Ctrlkey pressed, and the chevron buttons change to . Click one of these buttons to append contents of the current pane of the Differences viewer to the other pane.
If you keep
Shiftpressed, the chevrons turn into X. Click this button to revert changes.
Hover your mouse pointer over a warning, error stripe or just some section of source code on the scroll bar outside of the scroll box, and you will see a lens:
If the lens annoys you, get rid of it by clearing the check box on the context menu of the code analysis marker:
select multiple fragments in the "column mode"
Ctrl + Alt + Shift (
Cmd+Alt+Shift on Mac)拖动鼠标即可。
To select multiple fragments in the "column mode", keep
Control+Alt+Shift(on Windows and Linux) or
Cmd+Alt+Shift(on MAC), and drag your mouse cursor:
select multiple fragments of text
Alt + Shift 拖动鼠标即可。
You can easily select multiple fragments of text. To do that, it's enough to keep
Alt+Shiftand drag your mouse cursor:
select multiple words
Alt + Shift 后
To select multiple words, press
Alt+Shift, place the caret at each word to be selected and double-click the left mouse button.
Show quick doc on mouse move
Ctrl + Q）,只将鼠标指针移动到所需的符号，快速文档弹出窗口即自动显示。
Settinigs | Editor 中
Show quick doc on mouse move 复选框即。
You don't need to invoke quick documentation explicitly (
Ctrl+Q) - if you just move your mouse pointer over the desired symbol, the quick documentation pop-up window will show automatically.
To enable this feature, select the check box
Show quick doc on mouse movein the editor settings.
see all the available scratch files
To see all the available scratch files, choose Scratches view in the Project tool window.
copy rich text
Settinigs | Editor | Genernal 页面中的对应复选框即可。
Did you know that it's possible to copy rich text ?
Make sure that the check box
Copy rich text by defaultin the General page of the Editor settings/preferences is selected:
A special variant of the Code Completion feature invoked by pressing
Ctrl+空格twice allows you to complete XML tag names from namespaces not declared in the current file. If the namespace is not declared yet the declaration is generated automatically.
coding assistance for SQL
Alt + Enter | Inject language or reference | <SQL dialect>），然后使用SQL编码帮助。
You can inject SQL into a string literal (
Alt+Enter | Inject language or reference | <SQL dialect>) and then use coding assistance for SQL.
Ctrl + ALT + O 优化引用(
Shift + Ctrl + Alt + I 弹出输入框，输入
Unused Resources 回车确认搜索后，点击
Remove All Unused Resources删除所有无用资源。
Android Lint 还有其他更强大的功能。