Android Studio: Creating landscape layouts
Solution 1
You can actually use layout-land
in Android Studio as well it will show up in your res
directory like so:
If it doesn't show up make sure to have your project scope set to Project
and not Android
.
If you still don't see one you can create one by right clicking on the res directory and selecting New -> Android resource directory
and filling out the prompt below.
Also, once it's been created, you can easily switch from portrait to landscape in the layout preview via the orientation button found on the toolbar above the layout preview. It is pictured below:
Solution 2
You can also use option given in below image.
I hope you have understood.
Solution 3
The accepted answer is actually seriously outdated. In Android Studio 3.x.x, there is no need to create an extra layout folder (I am not sure this was necessary back then anyway).
There is also no need to change the project scope from Android to Project as the accepted answer tells you to.
There is also no need to edit any UI attributes and modes as the accepted answer says.
There are just 2 steps:
1) Open your base UI layout in DESIGN mode so that you see the actual GUI, such as buttons, icons etc. (do NOT open it as text, in the XML code view mode).
2) Click the icon marked in the below screenshot and, from the menu, select Create Landscape Variation (marked in the screenshot as 'Click 2nd').
Then, the Studio does all the job for you and it works like a charm. No need to add any extra code and no extra folders are created.
Enjoy.
Android Studio 3.1.4:
Solution 4
In the Project -> app -> src -> main -> res
Then Create Android resource directory, choose Orientation
mrd
Java and Android Development. PHP, Java, Android, iOS, Laravel, MySQL
Updated on May 08, 2020Comments
-
mrd almost 4 years
Until recently I used Eclipse, and in Eclipse I simply created a folder /res/layout-landscape and put alternate landscape layouts inside.
However, it seem in Android Studio 1.1.0, I can't do it that way. How do I create the folder for alternate landscape layouts?
-
mrd about 9 yearsThat is the exact answer. I coudn't see my layout-land folder because scope was et to "Android" instead of "Project". In this case Android studio will show the landscape version like a subitem of the normal layout. Tx. Pretty confusing, if one comes from Eclipse.
-
tentimes about 9 yearsIn my Android studio layout-land is NEVER created and I have to add it manually like you have shown. It is extremely weird and just pure luck I found your answer or I would never have been able to make a landscape layout. Really screwed up I think from the point of view of Android studio - people aren't psychic.
-
Anand Kumar over 7 yearsas @Mark Channer has said, Orientation should be selected and not UI Mode.