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

open preferences

go to XML code style

set predefined Android style


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:

enter image description here