Android Studio Tips Of the Day - Roundup #1

http://www.developerphil.com/android-studio-tips-of-the-day-roundup-1/

Turns out that I am not that good at keeping a commitment. The previous post was supposed to be a new series that I would contribute to but here we are, one year later!

So I am starting this all over again! Instead I am doing a series of daily posts on Google+ and I will post recaps here, much like what Daniel Lew did a while back.

Note that since I am starting a new series on G+, there will be some duplications with the previous post.

If you want the most up to date tips, follow me on google+ or subscribe to the Android Developer Tools CommunityPavlos-Petros Tournaris also collected all the current tips on github, So if you want a sneak peak at the content of the next blog posts, check it out!

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+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.

Android Studio Logo

Move Between Methods and Inner Classes

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.

Android Studio Logo

The File Structure Popup

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.

Android Studio Logo

The Call Hierarchy Popup

ctrl+alt+h  ctrl+alt+h

This will show you the possible paths between a method’s declaration and its invocations!

Android Studio Logo

Quick Definition Lookup

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.

Android Studio Logo

Collapse Expand Code Block

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

Android Studio Logo

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

Android Studio Logo

Find Actions

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

Android Studio Logo

Move Lines Up/Down

alt+shift+up/down  alt+shift+up/down

Yeah. This will move lines up or down. Not much more to say. Enjoy!

Android Studio Logo

Delete Line

cmd+backspace  ctrl+y

It deletes the current line or selection.

Android Studio Logo


  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值