Loading Seperate Layouts for Android in Landscape and Portrait


2011-10-05

There are many times while creating an app that you want to take advantage of the different widths and heights of a phone in landscape mode and one in portrait mode. An easy way to do this is to load a different layout file when in each orientation.

The files in the default layout directory (ProjectName/res/layout) are used in both orientations, unless you add a layout-land directory. Then all you have to do is put your customized landscape layout files in there and they will be loaded when the device switches to landscape mode.