in Quick and dirty

How to change your layout in Android landscape / portrait mode

In the res folder we are used to having a layout folder, in which we keep the XML files which describe our application’s layouts. This trick will show you how to improve the view in landscape or portrait mode, whichever you might need.

How do I quickly change my emulator from portrait to landscape and viceversa?

Use Ctrl + F11 to test around.

Can I only improve the layout and use no extra code?

The short answer is yes, definitely.

The layouts in /res/layout are applied to both portrait and landscape, unless you specify otherwise. Let’s assume we have /res/layout/home.xml for our homepage and we want it to look differently in the 2 layout types.

  1. create folder /res/layout-land (here you will keep your landscape adjusted layouts)
  2. copy home.xml there
  3. make necessary changes to it
  4. run the application in the emulator and test it using the Ctrl + F11 combination

Join the discussion


  1. my app works fine but only in portrait mode, when you rotate the emulator/phone the layout view is wrong, and it doesn’t adjust, i’ve created /res/the layout-land folder and did copy and made adjustments on the layout so everything fits to the landscape layout, Am I missing something? how can I make the app to work on landscape mode also?

  2. nevermind, it works fine, i just changed the name of the copy of main and that’s why it didn’t work, both of the layout.xml files have to be named the same

  3. What necessary changes to be done ?? that you mentioned in 3rd step. I have used files without changing but if says force close