@l...">

What is the purpose of layout.xml?

Why do people use layout.xml in their resources , for example:

 <resources> <item name="main" type="layout">@layout/main_twopanes</item> </resources> 

while there are folders for alternative resources for using specific XML for a specific configuration?

+6
source share
1 answer

this is called Layout Aliases link here:

To avoid duplication of the same file for tablets and TVs (and, as a result, its headache), you can use alias files. For example, you can define the following layouts:

And add these two files:

Res / value of Advanced /layout.xml:

 <resources> <item name="main" type="layout">@layout/main_twopanes</item> </resources> 

RES / value-sw600dp / layout.xml:

 <resources> <item name="main" type="layout">@layout/main_twopanes</item> </resources> 

These last two files have the same content, but they actually do not define the layout. They simply set main as an alias for main_twopanes. Since these files have large and sw600dp selectors, they apply to tablets and TVs regardless of the version of Android (tablets up to 3.2 and TVs correspond to a large one, and post-3.2 corresponds to sw600dp).

+3
source

Source: https://habr.com/ru/post/920033/


All Articles