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?
Select layouts , right-click and select New → Folder → Res Folder. This resource folder will represent a “feature category” that you want. You can easily create any type of file/folder in Android Studio.
XML-Based Layouts in Android In Android, an XML-based layout is a file that defines the different widgets to be used in the UI and the relations between those widgets and their containers. Android treats the layout files as resources. Hence the layouts are kept in the folder reslayout.
A layout defines the structure for a user interface in your app, such as in an activity. All elements in the layout are built using a hierarchy of View and ViewGroup objects. A View usually draws something the user can see and interact with.
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With