Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 216
Giorgio Vespucci Avatar asked Mar 23 '11 15:03

Giorgio Vespucci


People also ask

How do I create a layout folder?

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.

What is layout XML file?

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.

What is a layout file in Android Studio?

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.


1 Answers

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.

like image 91
Robby Pond Avatar answered Sep 28 '22 02:09

Robby Pond