屏幕尺寸和像素密度的资源限定符
?
每个限定符可以单独使用也可以和其他限定符一起使用
如 res/layout-small-long?? //小而长的屏幕的布局
?? ?res/layout-large??????????? //大屏幕的布局
??? res/drawable-hdpi???????? //高密度屏幕的 Drawable?
?
Declaring Tablet Layouts for Android 3.2
?
Screen configurationQualifier valuesDescriptionsmallestWidth(宽和高中比较小
的长度要比<N>大)
sw<N>dp
sw600dp
sw720dp
The fundamental size of a screen, as indicated by the shortest dimension of the available screen area. Specifically, the device's smallestWidth is the shortest of the screen's available height and width (you may also think of it as the "smallest possible width" for the screen). You can use this qualifier to ensure that, regardless of the screen's current orientation, your application's has at least?<N>
dps of width available for it UI.
For example, if your layout requires that its smallest dimension of screen area be at least 600 dp at all times, then you can use this qualifer to create the layout resources,?res/layout-sw600dp/
. The system will use these resources only when the smallest dimension of available screen is at least 600dp, regardless of whether the 600dp side is the user-perceived height or width. The smallestWidth is a fixed screen size characteristic of the device;?the device's smallestWidth does not change when the screen's orientation changes.
The smallestWidth of a device takes into account screen decorations and system UI. For example, if the device has some persistent UI elements on the screen that account for space along the axis of the smallestWidth, the system declares the smallestWidth to be smaller than the actual screen size, because those are screen pixels not available for your UI.
This is an alternative to the generalized screen size qualifiers (small, normal, large, xlarge) that allows you to define a discrete number for the effective size available for your UI. Using smallestWidth to determine the general screen size is useful because width is often the driving factor in designing a layout. A UI will often scroll vertically, but have fairly hard constraints on the minimum space it needs horizontally. The available width is also the key factor in determining whether to use a one-pane layout for handsets or multi-pane layout for tablets. Thus, you likely care most about what the smallest possible width will be on each device.
Available screen width
(宽度至少要比<N>大)
w<N>dp
w720dp
w1024dp
Specifies a minimum available width in dp units at which the resources should be used—defined by the?<N>
?value. The system's corresponding value for the width changes when the screen's orientation switches between landscape and portrait to reflect the current actual width that's available for your UI.
This is often useful to determine whether to use a multi-pane layout, because even on a tablet device, you often won't want the same multi-pane layout for portrait orientation as you do for landscape. Thus, you can use this to specify the minimum width required for the layout, instead of using both the screen size and orientation qualifiers together.
Available screen height
?
(高度至少要比<N>大)
?
h<N>dp
h720dp
h1024dp
Specifies a minimum screen height in dp units at which the resources should be used—defined by the?<N>
?value. The system's corresponding value for the height changes when the screen's orientation switches between landscape and portrait to reflect the current actual height that's available for your UI.
Using this to define the height required by your layout is useful in the same way as?w<N>dp
?is for defining the required width, instead of using both the screen size and orientation qualifiers. However, most apps won't need this qualifier, considering that UIs often scroll vertically and are thus more flexible with how much height is available, whereas the width is more rigid.
?
To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:
?Caution:?When developing for Android 3.2 and higher, you should not use the older screen size attributes in combination with the attributes listed above. Using both the new attributes and the older size attributes might cause unexpected behavior.