40

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
  • 4,561
  • 10
  • 54
  • 92
  • This is a good question. It is not clear from any tutorials how to do this in the latest Android studio. As it is such a common problem (you will nearly always need a landscape view) I am surprised it is not more clearly documented for Android studio. There are plenty of guides for eclipse that are now out of date. Thanks for your question. – tentimes Mar 18 '15 at 16:39

6 Answers6

78

You can actually use layout-land in Android Studio as well it will show up in your res directory like so:

layout-land

If it doesn't show up make sure to have your project scope set to Project and not Android.

Project Scope

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.

New directory

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:

Orientation Toggle

MrEngineer13
  • 38,642
  • 13
  • 74
  • 93
  • That 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. – mrd Mar 02 '15 at 17:37
  • 3
    In 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. – tentimes Mar 18 '15 at 16:00
  • 2
    as @Mark Channer has said, Orientation should be selected and not UI Mode. – Anand Kumar Feb 03 '17 at 08:21
45

You can also use option given in below image.

enter image description here

I hope you have understood.

pathe.kiran
  • 2,444
  • 1
  • 21
  • 27
27

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:

enter image description here

deLock
  • 762
  • 8
  • 16
  • 1
    So I literally do not have that "Create Landscape Variation" option. Any idea how to get it back? Or what might have replaced it? – Mark Puchala II Nov 06 '22 at 18:24
1

MrEngineer13's answer is spot on.

The only thing that I would add is that his screenshot may lead you to believe that you should be selecting 'UI Mode' from the 'Available qualifiers' list.

Just to clarify: after filling out the Directory name and Resource type, select 'Orientation' from Available qualifiers, which will lead you to the screenshot that MrEngineer13 provided.

1

In the Project -> app -> src -> main -> res

Then Create Android resource directory, choose Orientation

ketan
  • 19,129
  • 42
  • 60
  • 98
Gavin
  • 1,032
  • 7
  • 13
1

maybe this one is easier

android studio chipmunk :

enter image description here

Kakaranara
  • 97
  • 2
  • 7