blob: 99eb04e6955ee43230c6e83ecb750e9f9a2030f1 [file] [log] [blame]
Scott Main6aa2b622011-03-09 14:26:58 -08001page.title=Distributing to Specific Screens
Scott Main6afeb0e2013-04-16 21:05:51 -07002excludeFromSuggestions=true
Scott Main6aa2b622011-03-09 14:26:58 -08003parent.title=Supporting Multiple Screens
4parent.link=screens_support.html
5
6@jd:body
7
8<div id="qv-wrapper">
9<div id="qv">
10
11 <h2>Quickview</h2>
12 <ul>
13 <li>If necessary, you can control distribution of your application based on the device
14screen configuration</li>
15 </ul>
16
17 <h2>In this document</h2>
18 <ol>
Scott Main5e44f682011-10-07 01:33:09 -070019 <li><a href="#FilteringHansetApps">Declaring an App is Only for Handsets</a></li>
20 <li><a href="#FilteringTabletApps">Declaring an App is Only for Tablets</a></li>
Scott Main56e1deb2011-05-17 18:46:27 -070021 <li><a href="#MultiApks">Publishing Multiple APKs for Different Screens</a></li>
Scott Main6aa2b622011-03-09 14:26:58 -080022 </ol>
23
24 <h2>See also</h2>
25 <ol>
26 <li><a
27href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a></li>
28 <li><a
29href="{@docRoot}guide/practices/optimizing-for-3.0.html">Optimizing Apps for Android 3.0</a></li>
30 </ol>
31
32</div>
33</div>
34
35
36
37<p>Although we recommend that you design your application to function properly on multiple
38configurations of screen size and density, you can instead choose to limit the distribution of your
39application to certain types of screens, such as only tablets and other large devices or only
40handsets and similar-sized devices. To do so, you can enable filtering by external services such as
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -080041Google Play by adding elements to your manifest file that specify the screen configurations your
Scott Main6aa2b622011-03-09 14:26:58 -080042application supports.</p>
43
44<p>However, before you decide to restrict your application to certain screen configurations, you
45should understand the techniques for <a
46href="{@docRoot}guide/practices/screens_support.html">supporting multiple screens</a> and implement
47them to the best of your ability. By supporting multiple screens, your application can be made
Scott Main56e1deb2011-05-17 18:46:27 -070048available to the greatest number of users with different devices, using a single APK.</p>
Scott Main6aa2b622011-03-09 14:26:58 -080049
50
51
Scott Main5e44f682011-10-07 01:33:09 -070052<h2 id="FilteringHandsetApps">Declaring an App is Only for Handsets</h2>
Scott Main6aa2b622011-03-09 14:26:58 -080053
54<p>Because the system generally scales applications to fit larger screens well, you shouldn't
55need to filter your application from larger screens. As long as you follow the <a
56href="{@docRoot}guide/practices/screens_support.html#screen-independence">Best Practices for Screen
57Independence</a>, your application should work well on larger screens such as tablets. However, you
58might discover that your application can't scale up well or perhaps you've decided to publish two
59versions of your application for different screen configurations. In such a case, you can use the <a
60href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code
61&lt;compatible-screens>}</a> element to manage the distribution of your application based on
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -080062combinations of screen size and density. External services such as Google Play use this
Scott Main6aa2b622011-03-09 14:26:58 -080063information to apply filtering to your application, so that only devices that have a screen
64configuration with which you declare compatibility can download your application.</p>
65
66<p>The <a href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code
67&lt;compatible-screens>}</a> element must contain one or more {@code &lt;screen&gt;} elements. Each
68{@code &lt;screen&gt;} element specifies a screen configuration with which your application is
69compatible, using both the {@code android:screenSize} and {@code android:screenDensity} attributes.
70Each {@code &lt;screen&gt;} element <strong>must include both attributes</strong> to specify an
71individual screen configuration&mdash;if either attribute is missing, then the element is invalid
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -080072(external services such as Google Play will ignore it).</p>
Scott Main6aa2b622011-03-09 14:26:58 -080073
74<p>For example, if your application is compatible with only small and normal size screens,
75regardless of screen density, you must specify eight different {@code &lt;screen&gt;} elements,
76because each screen size has four density configurations. You must declare each one of
77these; any combination of size and density that you do <em>not</em> specify is considered a screen
78configuration with which your application is <em>not</em> compatible. Here's what the manifest
79entry looks like if your application is compatible with only small and normal screen sizes:</p>
80
81<pre>
82&lt;manifest ... >
Scott Main6aa2b622011-03-09 14:26:58 -080083 &lt;compatible-screens>
84 &lt;!-- all small size screens -->
85 &lt;screen android:screenSize="small" android:screenDensity="ldpi" />
86 &lt;screen android:screenSize="small" android:screenDensity="mdpi" />
87 &lt;screen android:screenSize="small" android:screenDensity="hdpi" />
88 &lt;screen android:screenSize="small" android:screenDensity="xhdpi" />
89 &lt;!-- all normal size screens -->
90 &lt;screen android:screenSize="normal" android:screenDensity="ldpi" />
91 &lt;screen android:screenSize="normal" android:screenDensity="mdpi" />
92 &lt;screen android:screenSize="normal" android:screenDensity="hdpi" />
93 &lt;screen android:screenSize="normal" android:screenDensity="xhdpi" />
94 &lt;/compatible-screens>
Scott Main5e44f682011-10-07 01:33:09 -070095 ...
Scott Main6aa2b622011-03-09 14:26:58 -080096 &lt;application ... >
97 ...
98 &lt;application>
99&lt;/manifest>
100</pre>
101
102<p class="note"><strong>Note:</strong> Although you can also use the <a
103href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code
104&lt;compatible-screens>}</a> element for the reverse scenario (when your application is not
105compatible with smaller screens), it's easier if you instead use the <a
106href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code
107&lt;supports-screens>}</a> as discussed in the next section, because it doesn't require you
108to specify each screen density your application supports.</p>
109
110
111
Scott Main6aa2b622011-03-09 14:26:58 -0800112
Scott Main5e44f682011-10-07 01:33:09 -0700113<h2 id="FilteringTabletApps">Declaring an App is Only for Tablets</h2>
114
115<p>If you don't want your app to be used on handsets (perhaps your app truly makes sense only on a
116large screen) or you need time to optimize it for smaller screens, you can prevent small-screen
117devices from downloading your app by using the <a
Scott Main6aa2b622011-03-09 14:26:58 -0800118href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code
119&lt;supports-screens>}</a> manifest element.</p>
120
Scott Main5e44f682011-10-07 01:33:09 -0700121<p>For example, if you want your application to be available only to tablet devices, you can declare
122the element in your manifest like this:</p>
Scott Main6aa2b622011-03-09 14:26:58 -0800123
124<pre>
125&lt;manifest ... >
Scott Main6aa2b622011-03-09 14:26:58 -0800126 &lt;supports-screens android:smallScreens="false"
127 android:normalScreens="false"
128 android:largeScreens="true"
Scott Main5e44f682011-10-07 01:33:09 -0700129 android:xlargeScreens="true"
130 android:requiresSmallestWidthDp="600" />
131 ...
Scott Main6aa2b622011-03-09 14:26:58 -0800132 &lt;application ... >
133 ...
Scott Main5e44f682011-10-07 01:33:09 -0700134 &lt;/application>
Scott Main6aa2b622011-03-09 14:26:58 -0800135&lt;/manifest>
136</pre>
137
Scott Main5e44f682011-10-07 01:33:09 -0700138<p>This describes your app's screen-size support in two different ways:</p>
139
140<ul>
141 <li>It declares that the app does <em>not</em> support the screen sizes "small" and
142"normal", which are traditionally not tablets.</li>
143 <li>It declares that the app requires a screen size with a minimum usable area that is at least
144600dp wide.</li>
145</ul>
146
147<p>The first technique is for devices that are running Android 3.1 or older, because those devices
148declare their size based on generalized screen sizes. The <a
149href="{@docRoot}guide/topics/manifest/supports-screens-element.html#requiresSmallest">{@code
150requiresSmallestWidthDp}</a> attribute is for devices running Android 3.2 and newer, which includes
151the capability for apps to specify size requirements based on a minimum number of
152density-independent pixels available. In this example, the app declares a minimum width requirement
153of 600dp, which generally implies a 7"-or-greater screen. </p>
154
155<p>Your size choice might be different, of course, based on how well your design works on different
156screen sizes; for example, if your design works well only on screens that are 9" or larger, you
157might require a minimum width of 720dp.</p>
158
159<p>The catch is that you must compile your application against Android 3.2 or higher in order to use
160the <code>requiresSmallestWidthDp</code> attribute. Older versions don't understand this attribute
161and will raise a compile-time error. The safest thing to do is develop your app against the platform
162that matches the API level you've set for <a
163href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">minSdkVersion</a
164>. When you're making final preparations to build your release candidate, change the build target to
165Android 3.2 and add the <code>requiresSmallestWidthDp</code> attribute. Android versions older than
1663.2 simply ignore that XML attribute, so there's no risk of a runtime failure.</p>
167
168<p>For more information about why the "smallest width" screen size is
169important for supporting different screen sizes, read <a
170href="http://android-developers.blogspot.com/2011/07/new-tools-for-managing-screen-sizes.html">New
171Tools for Managing Screen Sizes</a>.</p>
Scott Main6aa2b622011-03-09 14:26:58 -0800172
173<p class="caution"><strong>Caution:</strong> If you use the <a
174href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code
175&lt;supports-screens>}</a> element for the reverse scenario (when your application is not compatible
176with <em>larger</em> screens) and set the larger screen size attributes to {@code "false"}, then
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -0800177external services such as Google Play <strong>do not</strong> apply filtering. Your application
Scott Main6aa2b622011-03-09 14:26:58 -0800178will still be available to larger screens, but when it runs, it will not resize to fit the screen.
Scott Maindb909162011-06-22 14:28:44 -0700179Instead, the system will emulate a handset screen size (about 320dp x 480dp; see <a
180href="{@docRoot}guide/practices/screen-compat-mode.html">Screen Compatibility Mode</a> for more
181information). If you want
Scott Main6aa2b622011-03-09 14:26:58 -0800182to prevent your application from being downloaded on larger screens, use <a
183href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code
184&lt;compatible-screens>}</a>, as discussed in the previous section about <a
Scott Main5e44f682011-10-07 01:33:09 -0700185href="#FilteringHandsetApps">Declaring an App is Only for Handsets</a>.</p>
Scott Main6aa2b622011-03-09 14:26:58 -0800186
187<p>Remember, you should strive to make your application available to as many devices as possible by
188applying all necessary techniques for <a
189href="{@docRoot}guide/practices/screens_support.html">supporting multiple screens</a>. You should
190use <a href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code
191&lt;compatible-screens>}</a> or <a
192href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code
193&lt;supports-screens>}</a> only when you cannot provide compatibility on all screen configurations
194or you have decided to provide different versions of your application for different sets of screen
195configurations.</p>
196
Scott Main56e1deb2011-05-17 18:46:27 -0700197
198
199<h2 id="MultiApks">Publishing Multiple APKs for Different Screens</h2>
200
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -0800201<p>Although we recommend that you publish one APK for your application, Google Play allows
Scott Main56e1deb2011-05-17 18:46:27 -0700202you to publish multiple APKs for the same
203application when each APK supports a different set of screen configurations (as declared in
204the manifest file). For example, if you want to publish both a handset version and a tablet
205version of your application, but you're unable to make the same APK work for both screen sizes,
206you can actually publish two APKs for the same application listing. Depending on each device's
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -0800207screen configuration, Google Play will deliver it the APK that you've declared to support that
Scott Main56e1deb2011-05-17 18:46:27 -0700208device's screen.</p>
209
210<p>Beware, however, that publishing multiple APKs for the same application is
211considered an advanced feature and <strong>most applications should publish only one
212APK that can support a wide range of device configurations</strong>. Supporting multiple screen
213sizes, especially, is within reason using a single APK, as long as you follow the guide to
214<a href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a>.</p>
215
Dirk Dougherty4d7bc6552012-01-27 17:56:49 -0800216<p>If you need more information about how to publish multiple APKs on Google Play, read <a
Dirk Dougherty2b286bb2012-11-29 17:25:09 -0800217href="{@docRoot}google/play/publishing/multiple-apks.html">Multiple APK Support</a>.</p>