Just follow the following steps:
- Click on the encircled icon in Android Studio as shown in the following image:
- Select the option-‘Create Landscape Variation’ from the drop-down menu:
- That’s it! Android Studio will now create a landscape variation of your layout file. You can now edit the landscape layout separately.
- Click on the encircled button as shown below to toggle between portrait and landscape layouts:
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.
And create a layout xml file with the same name and provide the landscape layout in that file.
Notice how the xml layout files in the ‘layout’ and ‘layout-land’ folders have the same names.
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.
Ph.D. researcher at Friedrich-Schiller University Jena, Germany. I’m a physicist specializing in computational material science. I write efficient codes for simulating light-matter interactions at atomic scales. I like to develop Physics, DFT, and Machine Learning related apps and software from time to time. Can code in most of the popular languages. I like to share my knowledge in Physics and applications using this Blog and a YouTube channel.