Android Studio 使用技巧(1)
2015-06-02 01:06
501 查看
转载请注明本文出自Cym的博客(http://blog.csdn.net/cym492224103),谢谢支持!
Android Studio provides different keymaps (the mapping between shortcut keys and an action). You can see which keymap you are using in Settings->Keymap.
It wouldn’t be practical to list the shortcuts for every keymap so the following will be used:
Windows: Default
Linux: Default
OSX: Mac OSX 10.5+
cmd+shift+f7 ctrl+shift+f7
This will highlight every occurrence of a symbol in the current file. This is more than some simple pattern matching, it will actually understand the current scope and only highlight what is relevant.
You can then navigate up or down using the shortcuts from Edit → Find → Find Next/Previous
Additional tips:
Highlighting a “return” or a “throw” statement in a method will also highlight all the exit points of the method.
Highlighting the “extends” or the “implements” portion of the class definion will also highlight the methods that are overriden/implemented.
Highlighting an import will also highlight where it is used.
You can cancel the highlighting by pressing Escape.
ctrl+up/down alt+up/down
This wil move your cursor to the name of the next method or class in the current file.
If you are in the body of a method, going up will put the cursor on its name. This can be very useful because it puts you at the right place to refactor or find the usages of this method.
cmd+f12 ctrl+f12
The idea here is to show an outline of the current class and navigate in it. The best thing about it is that you can filter using your keyboard. This is a very efficient way to go to a method you know by name.
Additional tips:
You can use camel-case matching when typing to filter the list. Example: typing “oCr” would find “onCreate”
You can toggle a checkbox to also show anonymous classes. It could be useful in some cases like if you want to go directly to the onClick method in an OnClickListener.
ctrl+alt+h ctrl+alt+h
This will show you the possible paths between a method’s declaration and its invocations!
alt+space ctrl+shift+i
Ever wondered whats the implementation of a method or class but don’t want to lose your current context? Use this shortcut to look it up in place.
alt+plus/minus ctrl+shift+plus/minus
The goal of this feature is to let you hide things you don’t care about at the moment. In its simplest form, it will hide a whole code block (e.g. ignoring the import list when you open a new file). A more interesting use is that it will hide the boilerplate
around simple anonymous inner classes and make it look like a lambda expression.
Additional tip:
You can setup the default folding behaviour in the preferences at Editor → Code Folding
Toggle Bookmark
f3 f11
Toggle Bookmark With Mnemonic
alt+f3 ctrl+f11
If you assign a number, you can go back to the bookmark using this shortcut: ctrl+number
Show Bookmarks
cmd+f3 shift+f11
cmd+shift+a ctrl+shift+a
You can invoke any menu or action known to Android Studio by its name! This is pretty useful for commands that you use once in a while but don’t have a shortcut for.
Additional tip:
If there is a shortcut associated to the action, it will be shown by its side
alt+shift+up/down alt+shift+up/down
Yeah. This will move lines up or down. Not much more to say. Enjoy!
cmd+backspace ctrl+y
It deletes the current line or selection.
About Keymaps
Android Studio provides different keymaps (the mapping between shortcut keys and an action). You can see which keymap you are using in Settings->Keymap.It wouldn’t be practical to list the shortcuts for every keymap so the following will be used:
Windows: Default
Linux: Default
OSX: Mac OSX 10.5+
Highlight All the Things
cmd+shift+f7 ctrl+shift+f7This will highlight every occurrence of a symbol in the current file. This is more than some simple pattern matching, it will actually understand the current scope and only highlight what is relevant.
You can then navigate up or down using the shortcuts from Edit → Find → Find Next/Previous
Additional tips:
Highlighting a “return” or a “throw” statement in a method will also highlight all the exit points of the method.
Highlighting the “extends” or the “implements” portion of the class definion will also highlight the methods that are overriden/implemented.
Highlighting an import will also highlight where it is used.
You can cancel the highlighting by pressing Escape.
Move Between Methods and Inner Classes
ctrl+up/down alt+up/downThis wil move your cursor to the name of the next method or class in the current file.
If you are in the body of a method, going up will put the cursor on its name. This can be very useful because it puts you at the right place to refactor or find the usages of this method.
The File Structure Popup
cmd+f12 ctrl+f12The idea here is to show an outline of the current class and navigate in it. The best thing about it is that you can filter using your keyboard. This is a very efficient way to go to a method you know by name.
Additional tips:
You can use camel-case matching when typing to filter the list. Example: typing “oCr” would find “onCreate”
You can toggle a checkbox to also show anonymous classes. It could be useful in some cases like if you want to go directly to the onClick method in an OnClickListener.
The Call Hierarchy Popup
ctrl+alt+h ctrl+alt+hThis will show you the possible paths between a method’s declaration and its invocations!
Quick Definition Lookup
alt+space ctrl+shift+iEver wondered whats the implementation of a method or class but don’t want to lose your current context? Use this shortcut to look it up in place.
Collapse Expand Code Block
alt+plus/minus ctrl+shift+plus/minusThe goal of this feature is to let you hide things you don’t care about at the moment. In its simplest form, it will hide a whole code block (e.g. ignoring the import list when you open a new file). A more interesting use is that it will hide the boilerplate
around simple anonymous inner classes and make it look like a lambda expression.
Additional tip:
You can setup the default folding behaviour in the preferences at Editor → Code Folding
Bookmarks!
Toggle Bookmark
f3 f11
Toggle Bookmark With Mnemonic
alt+f3 ctrl+f11
If you assign a number, you can go back to the bookmark using this shortcut: ctrl+number
Show Bookmarks
cmd+f3 shift+f11
Find Actions
cmd+shift+a ctrl+shift+aYou can invoke any menu or action known to Android Studio by its name! This is pretty useful for commands that you use once in a while but don’t have a shortcut for.
Additional tip:
If there is a shortcut associated to the action, it will be shown by its side
Move Lines Up/Down
alt+shift+up/down alt+shift+up/downYeah. This will move lines up or down. Not much more to say. Enjoy!
Delete Line
cmd+backspace ctrl+yIt deletes the current line or selection.
相关文章推荐
- 关注Android安全 手机锁屏勒索国内首现身
- android天气1
- android天气2
- Android项目的目录结构
- ADT中添加libs下的jar包,增加了reference library,而没有增加Android private library的
- android 新浪微博登录获取access_token值的问题
- android studio引入第三方jar包
- marki-制作.9格式的素材图片
- Android Resources$NotFoundException: String resource ID #0x1
- Android动画之translate(位移动画)
- Android 实现记住用户名和密码的功能
- [016] 如何使用真机调试Android应用
- [014] Android应用程序签名详解
- [015] Android平台的专业术语
- [013] 百度地图API之城市POI搜索-获取所有结果(Android)
- [012] 百度地图API之公交换乘方案搜索(Android)
- [011] 百度地图API之POI搜索-发现你身边的兴趣点,如超市、餐厅、ATM...(Android)
- [010] 百度地图API之根据经纬度查询地址信息(Android)
- [009] 百度地图API之MyLocationOverlay的使用(Android)
- [008] 百度地图API之ItemizedOverlay的使用(Android)