Many developers want to display different la S (such as 5-inch and 7-inch devices) based on different screen sizes in this range ).
In Android 3.2, the "smallest-width" qualifier is introduced to solve this problem.
For example, the minimum width of a common 7-inch flat is 600dp, so if you want your program to use two windows on a screen of this size (a screen smaller than this size uses one window ),
Then you can use the two layout files above, as long as you replace the xlarge qualifier with sw600dp, you can see that in version 3.2 +, the screen restrictions are more detailed.
Devices whose minimum screen width is greater than or equal to 600dp use the layout-sw600dp/Main. xml window layout, while devices smaller than this size use the layout/Main. xml window layout.
However, in versions earlier than 3.2, because they do not know the sw600dp qualifier, you still need to use the xlarge qualifier at the same time. In this way, the content of your res/Layout-xlarge/Main. xml file is the same as that of the res/layout-sw600dp/Main. xml file.
The smallest-width qualifier shown above is only applicable to more than 3.2 devices. Therefore, you must also use (small, normal, large and xlarge) these delimiters allow your program to run in the system before 3.2. For example, if you want to design an interface that displays a window on your phone and two windows on a 7-inch tablet or larger device, you need these layout files:
Res/layout/Main. xml: Single Window Layout
Res/Layout-xlarge: Two window layout s
Res/layout-sw600dp: Two window la s
The two layout files are the same. One is for 3.2 + devices, and the other is for previous devices.
To avoid repeated layout files and make maintenance effort, you can use an alias file. For example, you can define the following layout file:
Res/layout/Main. XML, single window layout
Res/layout/main_twopanes.xml, two window layout s
Layout file content:
Res/Values-xlarge/layout. xml
Add XML code to favorites
<Resources>
<Item name = "Main" type = "layout"> @ layout/main_twopanes </item>
</Resources>
Res/values-sw600dp/layout. xml
Add XML code to favorites
<Resources>
<Item name = "Main" type = "layout"> @ layout/main_twopanes </item>
</Resources>
The two files share the same content, but they do not actually define the layout. They only set main as an alias for main_twopanes. Since the layout file has the xlarge and sw600dp delimiters, whether the system version is earlier than 3.2 or later, the layout will be used to meet the size requirements.