Android Studio - How to change layout

2020-07-10 10:34发布

问题:

In Eclipse, I can right - click on my layout (say LinearLayout) and click on Change Layout In Android Studio, I dont see anything like that. I do see Morphing but that will now show up at all times. For example, if you create simple HalloWorld with RelativeLayout, if you right click on that Layout while in Graphical mode, Morphing will not show. If you right click on a widget in that layout, Morphing shows but to change widget type, not layout type.

回答1:

If you want to change the Layout, you can do Two things:

OPTION 1 1. Simply click into your Xml file and select the "Text" option at the bottom on your screen

2.Change to layout

OPTION 2

1.Just drag another layout in Design and put your items in it, delete your old layout PS. you can have layouts in other layouts

Hope I helped!



回答2:

In Android Studio 3.6.3 the easiest way to change the Layout is to right-click on the layout in your Component Tree and click Convert view….



回答3:

The other option is to delete this layout and create new activity layout with type you want to be.



回答4:

You also can use AbsoluteLayout, just change RelativeLayout to AbsoluteLayout in activity_main.xml. With AbsoluteLayout you're more "free"