On Android Studio 3, Go to :
Preferences > Editor > Code style > XML then on Scheme switch to Default instead of Project.
You can then use those shortcuts to indent your code:
Ctrl + Alt + L
Option + Command + L
You can edit your code styles under File > Settings > Editor > Code Style > XML
If you want to preview a specific file, just paste that file’s contents into the preview window.
File > Settings > Editor > Code Style > XML
Now in layout file make sure you have selected wrap attributes as Wrap always.