supports-screens-element.jd revision db909162b2c26d12f56a7c0615977b83578c4acf
1page.title=<supports-screens>
2parent.title=The AndroidManifest.xml File
3parent.link=manifest-intro.html
4@jd:body
5
6<dl class="xml">
7
8<dt>syntax:</dt>
9<dd>
10<pre class="stx">
11&lt;supports-screens android:<a href="#resizeable">resizeable</a>=["true"| "false"]
12                  android:<a href="#small">smallScreens</a>=["true" | "false"]
13                  android:<a href="#normal">normalScreens</a>=["true" | "false"]
14                  android:<a href="#large">largeScreens</a>=["true" | "false"]
15                  android:<a href="#xlarge">xlargeScreens</a>=["true" | "false"]
16                  android:<a href="#any">anyDensity</a>=["true" | "false"]
17                  android:<a href="#requiresSmallest">requiresSmallestWidthDp</a>="<em>integer</em>"
18                  android:<a href="#compatibleWidth">compatibleWidthLimitDp</a>="<em>integer</em>"
19                  android:<a href="#largestWidth">largestWidthLimitDp</a>="<em>integer</em>"/&gt;
20</pre>
21</dd>
22
23<dt>contained in:</dt>
24<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
25
26<dt>description:</dt>
27<dd>Lets you specify the screen sizes your application supports and enable <a
28href="{@docRoot}guide/practices/screen-compat-mode.html">screen compatibility mode</a> for screens
29larger than what your application supports. It's important that you always use this element in your
30application to specify the screen sizes your application supports.
31
32<p>An application "supports" a given screen size if it resizes properly to fill the entire screen.
33Normal resizing applied by the system works well for most applications and you don't have to do any
34extra work to make your application work on screens larger than a handset device. However, it's
35often important that you optimize your application's UI for different screen sizes by providing <a
36href="{@docRoot}guide/topics/resources/providing-resources.html#AlternativeResources">alternative
37layout resources</a>. For instance, you might want to modify the layout of an activity
38when it is on a tablet compared to when running on a handset device.</p>
39
40<p>However, if your application does not work well when resized to fit different screen sizes, you
41can use the attributes of the {@code &lt;supports-screens&gt;} element to control whether your
42application should be distributed to smaller screens or have its UI scaled up ("zoomed") to fit
43larger screens using the system's <a
44href="{@docRoot}guide/practices/screen-compat-mode.html">screen compatibility mode</a>. When you
45have not designed for larger screen sizes and the normal resizing does not achieve the appropriate
46results, screen compatibility mode will scale your UI by emulating a <em>normal</em> size
47screen and medium density, then zooming in so that it fills the entire screen. Beware that this
48causes pixelation and blurring of your UI, so it's better if you optimize your UI for large
49screens.</p>
50
51<p class="note"><strong>Note:</strong> Android 3.2 introduces new attributes: {@code
52android:requiresSmallestWidthDp}, {@code android:compatibleWidthLimitDp}, and {@code
53android:largestWidthLimitDp}. If you're developing your application for Android 3.2 and higher,
54you should use these attributes to declare your screen size support, instead of the attributes
55based on generalized screen sizes.</p>
56
57<p>For more information about how to properly support different screen sizes so that you can avoid
58using screen compatibility mode with your application, read
59<a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a>.</p>
60
61
62<dt>attributes:</dt>
63
64<dd>
65<dl class="attr">
66
67  <dt><a name="resizeable"></a>{@code android:resizeable}</dt>
68  <dd>Indicates whether the application is resizeable for different screen sizes. This attribute is
69true, by default. If set false, the system will run your application in <a
70href="{@docRoot}guide/practices/screen-compat-mode.html">screen compatibility mode</a> on large
71screens.</p>
72
73  <p><strong>This attribute is deprecated</strong>. It was introduced to help applications
74transition from Android 1.5 to 1.6, when support for multiple screens was first introduced. You
75should not use it.</p>
76  </dd>
77  
78  <dt><a name="small"></a>{@code android:smallScreens}</dt>
79  <dd>Indicates whether the application supports smaller screen form-factors.
80     A small screen is defined as one with a smaller aspect ratio than
81     the "normal" (traditional HVGA) screen.  An application that does
82     not support small screens <em>will not be available</em> for
83     small screen devices from external services (such as Android Market), because there is little
84the platform can do to make such an application work on a smaller screen. This is {@code "true"} by
85default.
86  </dd>
87  
88  <dt><a name="normal"></a>{@code android:normalScreens}</dt>
89  <dd>Indicates whether an application supports the "normal" screen
90     form-factors.  Traditionally this is an HVGA medium density
91     screen, but WQVGA low density and WVGA high density are also
92     considered to be normal.  This attribute is "true" by default.
93  </dd>
94  
95  <dt><a name="large"></a>{@code android:largeScreens}</dt>
96  <dd>Indicates whether the application supports larger screen form-factors.
97     A large screen is defined as a screen that is significantly larger
98     than a "normal" handset screen, and thus might require some special care
99     on the application's part to make good use of it, though it may rely on resizing by the
100system to fill the screen.
101  <p>The default value for this actually varies between some versions, so it's better if
102you explicitly declare this attribute at all times. Beware that setting it "false" will
103generally enable <a href="{@docRoot}guide/practices/screen-compat-mode.html">screen
104compatibility mode</a>.</p>
105  </dd>
106
107  <dt><a name="xlarge"></a>{@code android:xlargeScreens}</dt>
108  <dd>Indicates whether the application supports extra large screen form-factors.
109     An xlarge screen is defined as a screen that is significantly larger
110     than a "large" screen, such as a tablet (or something larger) and may require special care
111     on the application's part to make good use of it, though it may rely on resizing by the
112system to fill the screen.
113  <p>The default value for this actually varies between some versions, so it's better if
114you explicitly declare this attribute at all times. Beware that setting it "false" will
115generally enable <a href="{@docRoot}guide/practices/screen-compat-mode.html">screen
116compatibility mode</a>.</p>
117     <p>This attribute was introduced in API level 9.</p>
118  </dd>
119  
120  <dt><a name="any"></a>{@code android:anyDensity}</dt>
121  <dd>Indicates whether the application includes resources to accommodate any screen
122     density.
123     <p>For applications that support Android 1.6 (API level 4) and higher, this is "true"
124by default and <strong>you should not set it "false"</strong> unless you're absolutely certain that
125it's necessary for your application to work. The only time it might be necessary to disable this
126is if your app directly manipulates bitmaps (see the <a
127href="{@docRoot}guide/practices/screens_support.html#DensityConsiderations">Supporting Multiple
128Screens</a> document for more information).</p>
129  </dd>
130  
131  <dt id="requiresSmallest">{@code android:requiresSmallestWidthDp}</dt>
132  <dd>This attribute specifies the minimum "smallest screen width" with which your
133application is compatible. In order for a device to be considered compatible with your
134application, the shortest side of the available screen space must be equal to or greater than this
135value.
136
137  <p class="caution"><strong>Caution:</strong> The Android system does not pay attention to this
138attribute, so it does not affect how your application behaves at runtime. Instead, it is used
139to enable filtering for your application on services such as Android Market. However,
140<strong>Android Market currently does not support this attribute</strong> (on Android 3.2), so you
141should continue using the other size attributes if your application does not support
142small screens.</p>
143
144<!-- 
145     #### Android Market does not support this attribute yet. ####
146
147<p>The width against which your value is compared takes into account screen decorations and system
148UI. For example, if the device has some persistent UI elements on the left or right edge of the
149display, the system declares the device's available width as one that is smaller than the actual
150screen size, accounting for these UI elements because those are screen pixels not available for your
151UI. Thus, the value you use should be the actual smallest width required by your layout.</p>
152<p>If your application properly resizes for smaller screen sizes (down to the
153<em>small</em> size or a minimum width of 320dp), you do
154not need to use this attribute. Otherwise, you should use a value for this attribute that
155matches the smallest value used by your application for the <a
156href="{@docRoot}guide/topics/resources/providing-resources.html#SmallestScreenWidthQualifier">
157smallest screen width qualifier</a> ({@code sw&lt;N&gt;dp}).</p>
158
159<p>For example, a typical handset screen has a minimum width of 320dp, a 7" tablet has a minimum
160width of 600dp, and a 10" tablet has a minimum width of 720dp. If the smallest available screen
161width on a device is less than the value you supply here, then the application is considered
162incompatible with that
163device. External services such as Android Market use this to determine whether a device
164is compatible with your application and prevent incompatible devices from installing it.</p>
165<p>Beginning with Android 3.2 (API level 13), using this attribute is the preferred way to
166specify the minimum screen size your application requires, instead of using the other attributes
167for small, normal, large, and xlarge screens. The advantage of using this attribute is that you
168have more control over exactly how much screen space your application needs at a minimum in order
169to properly display its UI, rather than relying on the generalized size groups.</p>
170<p>This attribute has no default value. If this attribute is not specified, then any of the old
171<code><a href="#small">smallScreens</a></code>, <code><a href="#normal">normalScreens</a></code>,
172<code><a href="#large">largeScreens</a></code>, or <code><a href="#xlarge">xlargeScreens</a></code>
173attributes are used instead to determine the smallest screen required.</p>
174-->
175     <p>This attribute was introduced in API level 13.</p>
176  </dd>
177
178  <dt id="compatibleWidth">{@code android:compatibleWidthLimitDp}</dt>
179  <dd>This attribute allows you to enable <a
180href="{@docRoot}guide/practices/screen-compat-mode.html">screen compatibility mode</a> as a
181user-optional feature by specifying the maximum "smallest screen width" for which your application
182is designed. If the smallest side of a device's available screen is greater than your value here,
183users can still install your application, but are offered to run it in screen compatibility mode. By
184default, screen compatibility mode is disabled and your layout is resized to fit the screen as
185usual, but a button is available in the system bar that allows the user to toggle screen
186compatibility mode on and off.
187  <p>If your application is compatible with all screen sizes and its layout properly resizes, you do
188not need to use this attribute.</p>
189  <p class="note"><strong>Note:</strong> Currently, screen compatibility mode emulates only handset
190screens with a 320dp width, so screen compatibility mode is not applied if your value for {@code
191android:compatibleWidthLimitDp} is larger than 320.</p>
192     <p>This attribute was introduced in API level 13.</p>
193  </dd>
194
195  <dt id="largestWidth">{@code android:largestWidthLimitDp}</dt>
196  <dd>This attribute allows you to force-enable <a
197href="{@docRoot}guide/practices/screen-compat-mode.html">screen compatibility mode</a> by specifying
198the maximum "smallest screen width" for which your application is designed. If the smallest side of
199a device's available screen is greater than your value here, the application runs in screen
200compatibility mode with no way for the user to disable it.
201  <p>If your application is compatible with all screen sizes and its layout properly resizes, you do
202not need to use this attribute. Otherwise, you should first consider using the <a
203href="#compatibleWidth">{@code android:compatibleWidthLimitDp}</a> attribute. You should use the
204{@code android:largestWidthLimitDp} attribute only when your application is functionally broken when
205resized for larger screens and screen compatibility mode is the only way that users should use
206your application.</p>
207  <p class="note"><strong>Note:</strong> Currently, screen compatibility mode emulates only handset
208screens with a 320dp width, so screen compatibility mode is not applied if your value for {@code
209android:largestWidthLimitDp} is larger than 320.</p>
210     <p>This attribute was introduced in API level 13.</p>
211  </dd>
212  
213
214</dl></dd>
215
216<!-- ##api level indication## -->
217<dt>introduced in:</dt>
218<dd>API Level 4</dd>
219
220<dt>see also:</dt>
221<dd>
222  <ul>
223    <li><a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple
224Screens</a></li>
225    <li>{@link android.util.DisplayMetrics}</li>
226  </ul>
227</dd>
228
229</dl>
230