Search code examples
androidxmlandroid-studioauto-generate

Prevent android studio to create more than a tag in xml files


In the new android studio 3.3 or 3.2 if we create a for example button auto generate create a text like

<Button android:layout_width="" android:layout_height=""/>      

but I would like something more like this

<Button 
        android:layout_width="" 
        android:layout_height=""/>

like old versions of Android studio is there a setting or something for that?


Solution

  • That is related to XML code wrapping. By default it should be on wrap always but maybe it's not in your Android Studio or they changed that in newer versions. Anyway you can find that by click on:

    Preferences -> Code Style (expand it) -> XML -> Android(Tab) -> Here you can find Layout Files and below options like: Wrap always, Don't wrap, Wrap if long etc. So set it on Wrap always and Apply changes and your XML code from now on should be wrapped.

    enter image description here