50 Android Studio Tips, Tricks & Resources

Ở bài viết này mình sẽ chia sẽ các tips, tricks, shortcuts để giúp cải thiện tốc độ phát triển ứng dụng.

  1. Material Colors theme for Android Logcat

Để thay đổi Android Studio Logcat bạn vào : Preferences (Settings on Windows / Linux machines) → Editor → Colors & Fonts → Android Logcat

Một số mã màu:

  • Assert #BA68C8
  • Debug #2196F3
  • Error #F44336
  • Info #4CAF50
  • Verbose #BBBBBB
  • Warning #FF9800

2. Ngăn ngừa Android Studio Logcat xoá log khi mà ứng dụng hiện tại bị crashes.

Bạn vào khungAndroid Monitor và chọn Edit filter configuration khi filter name thả xuống.

3. Sử dụng code style phù hợp to your IDE

Bạn vào Preferences → Code Style → Java và trongScheme thả xuống , bạn có thể chọn cho mình một style phù hợp.

Có 2 styles thông dụng:

4. Use split screen for increasing efficiency.

Để dùng tính năng này, bạn chuột phải trên tab chính của màn hình và chọn Split Vertically / Horizontally.

Bạn có thể đặt phím tắt cho thao tác này . Mở Preferences → Keycap và tìm Split Vertically. Sau đó bạn Add Keyboard Shortcut như hình.
Tôi thêm phím tắt control + alt + v cho màn hìnhvertical split ( chia theo chiều dọc)

5. Distraction Free Mode.

Bạn có thể enable tính năng này: View → Enter Distraction Free Mode

6. Use Live Templates

  • Bạn có thể sử dụng phím tắt: cmd + j (Windows / Linux: ctrl + j).

Bạn có thể sử dụng các template có sẵn như Toasts or if

Shortcuts and helpful commands

1. The best and the most helpful command is Search for command:
cmd + shift + a (Windows / Linux: ctrl + shift + a).

Let’s say you want to close current tab and you don’t know how. You just type: close and you’ll get a proper shortcut / command.

2. Choose from the last copy / pastes (manage your clipboard):
cmd + shift + v (Windows / Linux: ctrl + shift + v).
By default there are 5 last copy/paste items.

3. Enable multicursor feature: control + g (alt + j for Windows / Linux).

A detailed article about this feature is provided by Bartek Lipinski on Medium. Highly recommended!

4. Open a class: cmd + o (Windows / Linux: ctrl + n).

5. Open any file: cmd + shift + o (Windows / Linux: ctrl + shift + n).

6. Open symbol: cmd + option + o (Windows / Linux: alt + shift + n).

7. Go to implementation: cmd + option + b (Windows / Linux:
ctrl + alt + b).
Let’s say you have an interface. By clicking on the interface’s name and then clicking the Go to implementation shortcut, you will be redirected to classes which implement that interface.

8. Go to declaration: cmd + b (Windows / Linux: ctrl + b).
It allows you to quickly check and go to a declaration of a class, method or a variable.

9. Go to type declaration: control + shift + b (Windows / Linux:
ctrl + shift + b).
Let’s say you defined:

Employee employee = new Employee(“Michal”);

When your caret is on employee and you click the shortcut, you will be redirected to the Employee class.

10. Go to super: cmd + u (Windows / Linux: ctrl + u).
For instance, you override some method. When your caret in on the method’s name and you click Go to super shortcut, you will be redirected to the parent method.

11. Move between tabs: cmd + shift + [ (move left) or cmd + shift + ](move right) (Windows / Linux: alt + ← / →).

12. Move between Design / Text tabs in layout’s view:
control + shift + ← / → (Windows / Linux: alt + shift + ← / →).

13. Close a current tab: cmd + w (Windows / Linux: ctrl + shift + a).

14. Hide all windows: cmd + shift + F12 (Windows / Linux:
ctrl + shift + F12).

15. Minimize Android Studio instance: cmd + m (Windows / Linux:
ctrl + m).

16. Format your code: cmd + option + l (Windows / Linux:
ctrl + alt + l).

17. Auto-indent lines: control + option + i (Windows / Linux:
ctrl + alt + i).

18. Implement methods: control + i (Windows / Linux: ctrl + i).
Let’s say you implement an interface. Then, you can quickly import all methods provided by that interface, just by clicking this shortcut.

19. Smart code completion (filters the list of methods and variables by expected type): control + shift + space (Windows / Linux: ctrl + shift + space).

20. Find: cmd + f (Windows / Linux: ctrl + f).

21. Find and replace: cmd + r (Windows / Linux: ctrl + r).

22. Move hardcoded strings to resources: option + return (Windows / Linux: alt + enter). The shortcut must be used when a caret is on a text. Check the gif below:

If you use that shortcut globally, the IDE will do Project quick fix (show intention actions and quick fixes).

23. Build and run: control + r (Windows / Linux: shift + F10).

Plugins: Một số plugins hữu ích

Nguồn: St

Nguyễn Linh

Chia sẻ để cùng tiến bộ...