Just a selection of tips, tricks and shortcuts that have been useful in my transition to Android Studio from Eclipse. I use OS X mainly so I will name the shortcuts to make it easier for you to look them up on your system.
This is mainly for myself but you may also find it useful.
- ^ (control)
- ↑ (arrow)
- ⇧ (shift)
Just click “Help > Default Keymap Reference” to get a PDF list of keyboard shortcuts for reference. If you’re using OS X then it is recommended to use the “10.5+” keymap.
Awesome selection mode
Put your cursor in the middle of some line in some method. Now press the following a few times (option and up arrow).
Action name lookup
⌘ ⇧ A
This is one of my favourite things about Android Studio. You can open a dialogue and enter text to find contextual options and actions. If a keyboard shortcut is assigned to one of these it will also show that too.
Organise / optimize imports.
I use this a lot in Eclipse. It will reorder your imports and remove unused ones. Depending on your settings it may also collapse multiple imports from one package to * after a certain threshold.
The first time you use this in Android studio it will ask you for the scope you wish to apply the operation on. Keep it to the current file to behave like eclipse.
Format / reformat code
⌘ ⌥ L
This one is used to change the layout of your code so that it matches the programming style that is defined in the settings. Similarly to the optimize imports action this action will prompt you for the scope to apply to. I personally leave it to ‘selection’.
Open Resource, Open Type
In eclipse I would often use ⌘⇧R to open source files, xml and other textual resources and ⌘⇧T to open up class types that were in libraries.
In Android studio you can open classes in your project or in any library you use like so:
If you want to open a different type of resource in your project (xml, text, image etc.) you would use:
⌘ ⇧ O
A super-awesome variation on ⌘ ⇧ O is that you can press the key combination again to also look outside your project too. For example search for “*9.png” and you’ll see all the 9-patch PNGs in the android platforms that you have downloaded via the SDK manager!