Use the re-format code shortcut in the project file view on the desired root folder(s).
This is how it works in Android Studio 3.5
Right click in your project or lib -> Reformat Code
See the image below:
Select what you want (clean up code will reformat your code)
Wait until the progress finish.
that's it!
Good coding!