'How to correct indentation in Android Studio [duplicate]

In Eclipse we can correct indentation by pressing Ctrl + Shift + F.

How can I correct indentation (format code) in Android Studio?



Solution 1:[1]

Select the code and press

  • On Windows: Ctrl + Alt + L
  • On MAC: CMD + Option + L

Solution 2:[2]

File->settings->Keymap and select 'eclipse' from keymap dropdown.

Solution 3:[3]

File->settings->Keymap and select 'eclipse' from keymap dropdown.

By doing this all the shortcuts of eclipse will work in studio also

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Suragch
Solution 2 Mohit Suthar
Solution 3