Android Studio: Reformat Code Options

June 6, 2020

IMG_0662.jpeg

By default, Option+Cmd+L in Android Studio on a Mac is used to reformat code to comply with settings such as spacing/indentation, etc. Often you’d also want it to remove unused imports. To do so, open Reformat Code dialog by double-tapping on the Shift button and add a checkmark for the Optimize imports option.

Screen Shot 2020-06-06 at 5.46.24 PM.png

Now every time you use Option+Cmd+L to format a file, unused imports will also be deleted!

If you’d like to reformat all files in a project at once, select Project (top-level) in Project view

Screen Shot 2020-06-06 at 6.06.10 PM.png

Now press Option+Cmd+L to be presented with a Reformat Code dialog. Hit Run and all source files in the project will be reformatted.

 
Previous
Previous

Inject vs Provides vs Binds in Dagger and Hilt

Next
Next

Changing Default Android Studio view