7

I have the following layout:

enter image description here

I need the following layout in portrait mode:

enter image description here

But instead of that I obtain the following one that I don't know how to modify it:

enter image description here

How can I do that?

Lechucico
  • 1,914
  • 7
  • 27
  • 60

5 Answers5

14

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

enter image description here

Shid
  • 1,336
  • 1
  • 15
  • 18
4

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.

enter image description here

When now changing the orientation to landscape, Android will use this layout.

Rene Ferrari
  • 4,096
  • 3
  • 22
  • 28
4

Create a layout-land folder in res folder and create xml with the same name in this folder.

2

Just create layout-land folder near layout folder and create xml with the same name.

1

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.

Sinan Ceylan
  • 1,043
  • 1
  • 10
  • 14