Android Studio: Creating landscape layouts

血红的双手。 提交于 2019-11-27 01:00:35

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:

You can also use option given in below image.

I hope you have understood.

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:

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.

Gavin

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

Then Create Android resource directory, choose Orientation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!