From 759c89322548dd88b35a3f3b4b5e636c515bbc57 Mon Sep 17 00:00:00 2001
From: Scott Main
The reason designing for 7" tablets is tricky when using the generalized size groups is that a 7" tablet is technically in the same group as a 5" handset (the large group). While these two devices are seemingly close to each other in size, the amount of space for an application's UI is significantly different, as is the style of user interaction. Thus, a 7" and 5" -screen should not always use the same layout. To make it possible for these two kinds of screens to -offer different layouts, Android now allows you to specify your layout resources based on the width -and/or height that's actually available for your application's layout, specified in dp units.
+screen should not always use the same layout. To make it possible for you to provide different +layouts for these two kinds of screens, Android now allows you to specify your layout resources +based on the width and/or height that's actually available for your application's layout, specified +in dp units.For example, after you've designed the layout you want to use for tablet-style devices, you might determine that the layout stops working well when the screen is less than 600dp wide. This threshold @@ -668,16 +669,20 @@ such, you can now specify that these layout resources should be used only when t
You should either pick a width and design to it as your minimum size, or test what is the smallest width your layout supports once it's complete.
+Note: Remember that all the figures used with these new size APIs +are density-indpendent pixel (dp) values and your layout dimensions should also always be defined +using dp units, because what you care about is the amount of screen space available after the system +accounts for screen density (as opposed to using raw pixel resolution). For more information about +density-indpendent pixels, read Terms and concepts, earlier in this +document.
+The numbers describing the width and height available for your layout are all in dp -units—remember that your layout dimensions should always be defined using dp units, -because what you care about is the amount of space available after the system accounts for screen -density (as opposed to using raw pixel numbers). The different resource configurations that you can -specify based on the space available for your layout are summarized in table 2. When building an -application for Android 3.2 and higher, you should use these new qualifiers instead of those for the -traditional screen size groups (small, normal, large, and xlarge).
+The different resource configurations that you can specify based on the space available for your +layout are summarized in table 2. These new qualifiers offer you more control over the specific +screen sizes your application supports, compared to the traditional screen size groups (small, +normal, large, and xlarge).
Note: The sizes that you specify using these qualifiers are not the actual screen sizes. Rather, the sizes are for the width or height in dp @@ -694,30 +699,40 @@ the space available for your layout and you must account for it in your design.< (introduced in Android 3.2).
Screen configuration | Qualifier values | Description |
---|---|---|
Smallest available width | +||
smallestWidth | sw<N>dp Examples: sw600dp sw720dp |
- Specifies the "smallest width" in dp units that must be available to your
-application in order for the resources to be used—defined by the This is the most important size configuration value, because it replaces the old screen size -buckets with a discrete number that specifies the effective size available for your UI. This number -is based on width because that is most 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. +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 {@code <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, {@code +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 width | +Available screen width | w<N>dp Examples: w720dp @@ -735,7 +750,7 @@ of using both the screen size and orientation qualifiers together. |
Available height | +Available screen height | h<N>dp Examples: h720dp @@ -764,6 +779,10 @@ will depend on your particular design—maybe you need a 720dp width for you maybe 600dp is enough, or 480dp, or some number between these. Using these qualifiers in table 2, you are in control of the precise size at which your layout changes. + For more discussion about these size configuration qualifiers, see the +Providing Resources document. +Configuration examples@@ -836,17 +855,16 @@ href="{@docRoot}guide/topics/manifest/supports-screens-element.html"><support manifest element:
|