Android layout folders: layout, layout-port, layout-land
I'm not sure to have understood well the role played by the several Android /res/layout
folders.
layout
: general layouts
layout-port
: layout for widget that must change for portrait orientation
layout-land
: layout for widget that must change for landscape orientation
For example in the Home sample application, under layout-port
and layout-land
folders there is only one home.xml
file.
Have I understood right?
If you are in landscape or portrait Android looks for the layout file in either the -port or -land directory first, if it's not found then it falls back to the default layout directory.
You can read about providing alternative resources here. There are many more options than just land and port.
If you put home.xml
in layout-port
folder, when your device is in portrait orientation it will use the file: layout-port/home.xml
.
If you put home.xml
in layout-land
folder, when your device in landscape orientation it will use the file: layout-land/home.xml
.
Meaning for different orientation modes like portrait and landscape... we use two home.xml
files; one in layout-port
and the other in layout-land
. If on the other hand you want to use the same layout file for both, you can just put home.xml
in the layout
folder and remove it from layout-land
and layout-port
.
Create folder in res layout-land
or layout-port
layout-port:
layout for widget that must change for portrait orientation
layout-land:
layout for widget that must change for landscape orientation