How to create an alternate layout for Landscape Mode in Android Studio? [Solution]

Just follow the following steps:

  1. Click on the encircled icon in Android Studio as shown in the following image:
    alternate layout for background android studio 1
  2. Select the option-‘Create Landscape Variation’  from the drop-down menu:
    alternate layout for background android studio 2
  3. That’s it! Android Studio will now create a landscape variation of your layout file. You can now edit the landscape layout separately.
    alternate layout for background android studio 3
  4. Click on the encircled button as shown below to toggle between portrait and landscape layouts:
    alternate layout for background android studio 4

Not using ANDROID STUDIO??
If you are using any other IDE like Eclipse then alternatively you can create a folder ‘layout-land’ inside the ‘res’ folder of your app.

alternate layout for background android studio 5

And create a layout xml file with the same name and provide the landscape layout in that file.
alternate layout for background android studio 6

Notice how the xml layout files in the ‘layout’ and ‘layout-land’ folders have the same names.
alternate layout for background android studio 7

That’s it!!! I hope that helped.
If you have any questions or doubts drop them in the comments section below.

Watch the following video for a video version of the above tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *