I have the following layout:
I need the following layout in portrait mode:
But instead of that I obtain the following one that I don't know how to modify it:
How can I do that?
Fastest way for Android Studio 3.x.x
1.Go to the design tab of the activity layout
2.At the top you should press on the orientation for preview button, there is a option to create a landscape layout (check image), a new folder will be created as your xml layout file for that particular orientation
You could create a seperate Layout for Landscape mode.Just name it the name as your current layout but make sure to add it in the folder layout-land.
Right click on res - layout
and then Add New
and for the folder write layout-land
. Name should be - as said before - the same as your current layout.
When now changing the orientation to landscape, Android will use this layout.
Create a layout-land
folder in res
folder and create xml
with the same name in this folder.
Just create layout-land
folder near layout folder and create xml with the same name.
No need to create layout-land. Google has an open sourced FlexBox Layout that works adaptive on screen size /orientation changes like CSS. Have a look at google's developer site for examples.