Unexpected auto-formatting of XML layout in Android Studio
for me it's working
Open Settings > Editor > Code Style > XML > Arrangements
Click Set from... text
Select Predefined Styles > Android
Click Apply button
Update
if you facing same issue with
Android Studio 3.5
please check below article
Android Studio 3.5 Upgrade XML Reformatting Problems
Open File > Settings > Editor > Code Style > XML
Now in layout file make sure you have selected wrap attributes as Wrap always
Like below screenshot: