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?
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.
- create folder
/res/layout-land(here you will keep your landscape adjusted layouts)
- make necessary changes to it
- run the application in the emulator and test it using the
Ctrl + F11combination
Categories: Quick and dirty