Open In App

How to Create Landscape Layout in Android Studio?

Improve
Improve
Like Article
Like
Save
Share
Report

In Android, whenever the user switches to landscape mode an issue is encountered in which some of the widgets become invisible (as you can see in the below image) and so in this scenario, there is a need to design a separate layout for the landscape mode. So in android, every application is designed in almost both the orientations i.e Portrait and Landscape. But by default Android Studio gives the option to design the application in Portrait mode but for Landscape mode, we need to create a Landscape Layout folder under the res folder. As per Android developer website guidelines, the name of this folder should be “layout-land”.

THe problem with landscape mode

We are going to discuss two methods to create a landscape layout in android studio.

Method 1:

Step 1: If the project is already opened in the “Android” mode then change the project to “Project” mode as shown in the below image.

Project mode

Step 2: Go to app > src > main > res > right-click > New > Android Resource Directory and one pop up will be prompted as shown below. Select Resource type as layout then go to Orientation and then click on the >> icon.

Prompt

Step 3: Now in the Screen orientation select Landscape and the directory name automatically change to layout-land and let the Directory name as layout-land and don’t change it.

Step 4: Go to the layout-land > right-click > New > XML > Layout XML File and name the file. 

layout-land

Step 5: Now cut the layout.xml file and paste it under the layout-land folder. Open the XML file and you will get the Landscape mode

cut the file

If you want to redesign the activity_main.xml in Landscape mode then copy the activity_main.xml file from the layout folder to the layout-land folder. Please refer to this article to Design the Landscape and Portrait Mode of Application in Android. Refer to the following video to get the whole steps:

Method 2

Method 2 is very easy to implement. In fact In Android Studio 3.x.x, there is no need to create an extra layout folder. There are only two steps to implement the method. 

Step 1: Open the base UI layout in DESIGN mode so that you see the actual GUI, such as Buttons, icons, etc. 

Landscape mode

Step 2: Click the icon marked in the below screenshot and, from the menu, select Create Landscape Variation. Then the corresponding Landscape file will be created automatically named as land\xml file name.

Landscape mode


Last Updated : 22 Oct, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads