| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 1 | page.title=Distributing to Specific Screens |
| Scott Main | 6afeb0e | 2013-04-16 21:05:51 -0700 | [diff] [blame] | 2 | excludeFromSuggestions=true |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 3 | parent.title=Supporting Multiple Screens |
| 4 | parent.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 |
| 14 | screen configuration</li> |
| 15 | </ul> |
| 16 | |
| 17 | <h2>In this document</h2> |
| 18 | <ol> |
| Scott Main | 5e44f68 | 2011-10-07 01:33:09 -0700 | [diff] [blame] | 19 | <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 Main | 56e1deb | 2011-05-17 18:46:27 -0700 | [diff] [blame] | 21 | <li><a href="#MultiApks">Publishing Multiple APKs for Different Screens</a></li> |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 22 | </ol> |
| 23 | |
| 24 | <h2>See also</h2> |
| 25 | <ol> |
| 26 | <li><a |
| 27 | href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a></li> |
| 28 | <li><a |
| 29 | href="{@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 |
| 38 | configurations of screen size and density, you can instead choose to limit the distribution of your |
| 39 | application to certain types of screens, such as only tablets and other large devices or only |
| 40 | handsets and similar-sized devices. To do so, you can enable filtering by external services such as |
| Dirk Dougherty | 4d7bc655 | 2012-01-27 17:56:49 -0800 | [diff] [blame] | 41 | Google Play by adding elements to your manifest file that specify the screen configurations your |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 42 | application supports.</p> |
| 43 | |
| 44 | <p>However, before you decide to restrict your application to certain screen configurations, you |
| 45 | should understand the techniques for <a |
| 46 | href="{@docRoot}guide/practices/screens_support.html">supporting multiple screens</a> and implement |
| 47 | them to the best of your ability. By supporting multiple screens, your application can be made |
| Scott Main | 56e1deb | 2011-05-17 18:46:27 -0700 | [diff] [blame] | 48 | available to the greatest number of users with different devices, using a single APK.</p> |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 49 | |
| 50 | |
| 51 | |
| Scott Main | 5e44f68 | 2011-10-07 01:33:09 -0700 | [diff] [blame] | 52 | <h2 id="FilteringHandsetApps">Declaring an App is Only for Handsets</h2> |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 53 | |
| 54 | <p>Because the system generally scales applications to fit larger screens well, you shouldn't |
| 55 | need to filter your application from larger screens. As long as you follow the <a |
| 56 | href="{@docRoot}guide/practices/screens_support.html#screen-independence">Best Practices for Screen |
| 57 | Independence</a>, your application should work well on larger screens such as tablets. However, you |
| 58 | might discover that your application can't scale up well or perhaps you've decided to publish two |
| 59 | versions of your application for different screen configurations. In such a case, you can use the <a |
| 60 | href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code |
| 61 | <compatible-screens>}</a> element to manage the distribution of your application based on |
| Dirk Dougherty | 4d7bc655 | 2012-01-27 17:56:49 -0800 | [diff] [blame] | 62 | combinations of screen size and density. External services such as Google Play use this |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 63 | information to apply filtering to your application, so that only devices that have a screen |
| 64 | configuration 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 | <compatible-screens>}</a> element must contain one or more {@code <screen>} elements. Each |
| 68 | {@code <screen>} element specifies a screen configuration with which your application is |
| 69 | compatible, using both the {@code android:screenSize} and {@code android:screenDensity} attributes. |
| 70 | Each {@code <screen>} element <strong>must include both attributes</strong> to specify an |
| 71 | individual screen configuration—if either attribute is missing, then the element is invalid |
| Dirk Dougherty | 4d7bc655 | 2012-01-27 17:56:49 -0800 | [diff] [blame] | 72 | (external services such as Google Play will ignore it).</p> |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 73 | |
| 74 | <p>For example, if your application is compatible with only small and normal size screens, |
| 75 | regardless of screen density, you must specify eight different {@code <screen>} elements, |
| 76 | because each screen size has four density configurations. You must declare each one of |
| 77 | these; any combination of size and density that you do <em>not</em> specify is considered a screen |
| 78 | configuration with which your application is <em>not</em> compatible. Here's what the manifest |
| 79 | entry looks like if your application is compatible with only small and normal screen sizes:</p> |
| 80 | |
| 81 | <pre> |
| 82 | <manifest ... > |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 83 | <compatible-screens> |
| 84 | <!-- all small size screens --> |
| 85 | <screen android:screenSize="small" android:screenDensity="ldpi" /> |
| 86 | <screen android:screenSize="small" android:screenDensity="mdpi" /> |
| 87 | <screen android:screenSize="small" android:screenDensity="hdpi" /> |
| 88 | <screen android:screenSize="small" android:screenDensity="xhdpi" /> |
| 89 | <!-- all normal size screens --> |
| 90 | <screen android:screenSize="normal" android:screenDensity="ldpi" /> |
| 91 | <screen android:screenSize="normal" android:screenDensity="mdpi" /> |
| 92 | <screen android:screenSize="normal" android:screenDensity="hdpi" /> |
| 93 | <screen android:screenSize="normal" android:screenDensity="xhdpi" /> |
| 94 | </compatible-screens> |
| Scott Main | 5e44f68 | 2011-10-07 01:33:09 -0700 | [diff] [blame] | 95 | ... |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 96 | <application ... > |
| 97 | ... |
| 98 | <application> |
| 99 | </manifest> |
| 100 | </pre> |
| 101 | |
| 102 | <p class="note"><strong>Note:</strong> Although you can also use the <a |
| 103 | href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code |
| 104 | <compatible-screens>}</a> element for the reverse scenario (when your application is not |
| 105 | compatible with smaller screens), it's easier if you instead use the <a |
| 106 | href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code |
| 107 | <supports-screens>}</a> as discussed in the next section, because it doesn't require you |
| 108 | to specify each screen density your application supports.</p> |
| 109 | |
| 110 | |
| 111 | |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 112 | |
| Scott Main | 5e44f68 | 2011-10-07 01:33:09 -0700 | [diff] [blame] | 113 | <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 |
| 116 | large screen) or you need time to optimize it for smaller screens, you can prevent small-screen |
| 117 | devices from downloading your app by using the <a |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 118 | href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code |
| 119 | <supports-screens>}</a> manifest element.</p> |
| 120 | |
| Scott Main | 5e44f68 | 2011-10-07 01:33:09 -0700 | [diff] [blame] | 121 | <p>For example, if you want your application to be available only to tablet devices, you can declare |
| 122 | the element in your manifest like this:</p> |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 123 | |
| 124 | <pre> |
| 125 | <manifest ... > |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 126 | <supports-screens android:smallScreens="false" |
| 127 | android:normalScreens="false" |
| 128 | android:largeScreens="true" |
| Scott Main | 5e44f68 | 2011-10-07 01:33:09 -0700 | [diff] [blame] | 129 | android:xlargeScreens="true" |
| 130 | android:requiresSmallestWidthDp="600" /> |
| 131 | ... |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 132 | <application ... > |
| 133 | ... |
| Scott Main | 5e44f68 | 2011-10-07 01:33:09 -0700 | [diff] [blame] | 134 | </application> |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 135 | </manifest> |
| 136 | </pre> |
| 137 | |
| Scott Main | 5e44f68 | 2011-10-07 01:33:09 -0700 | [diff] [blame] | 138 | <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 |
| 144 | 600dp wide.</li> |
| 145 | </ul> |
| 146 | |
| 147 | <p>The first technique is for devices that are running Android 3.1 or older, because those devices |
| 148 | declare their size based on generalized screen sizes. The <a |
| 149 | href="{@docRoot}guide/topics/manifest/supports-screens-element.html#requiresSmallest">{@code |
| 150 | requiresSmallestWidthDp}</a> attribute is for devices running Android 3.2 and newer, which includes |
| 151 | the capability for apps to specify size requirements based on a minimum number of |
| 152 | density-independent pixels available. In this example, the app declares a minimum width requirement |
| 153 | of 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 |
| 156 | screen sizes; for example, if your design works well only on screens that are 9" or larger, you |
| 157 | might 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 |
| 160 | the <code>requiresSmallestWidthDp</code> attribute. Older versions don't understand this attribute |
| 161 | and will raise a compile-time error. The safest thing to do is develop your app against the platform |
| 162 | that matches the API level you've set for <a |
| 163 | href="{@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 |
| 165 | Android 3.2 and add the <code>requiresSmallestWidthDp</code> attribute. Android versions older than |
| 166 | 3.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 |
| 169 | important for supporting different screen sizes, read <a |
| 170 | href="http://android-developers.blogspot.com/2011/07/new-tools-for-managing-screen-sizes.html">New |
| 171 | Tools for Managing Screen Sizes</a>.</p> |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 172 | |
| 173 | <p class="caution"><strong>Caution:</strong> If you use the <a |
| 174 | href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code |
| 175 | <supports-screens>}</a> element for the reverse scenario (when your application is not compatible |
| 176 | with <em>larger</em> screens) and set the larger screen size attributes to {@code "false"}, then |
| Dirk Dougherty | 4d7bc655 | 2012-01-27 17:56:49 -0800 | [diff] [blame] | 177 | external services such as Google Play <strong>do not</strong> apply filtering. Your application |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 178 | will still be available to larger screens, but when it runs, it will not resize to fit the screen. |
| Scott Main | db90916 | 2011-06-22 14:28:44 -0700 | [diff] [blame] | 179 | Instead, the system will emulate a handset screen size (about 320dp x 480dp; see <a |
| 180 | href="{@docRoot}guide/practices/screen-compat-mode.html">Screen Compatibility Mode</a> for more |
| 181 | information). If you want |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 182 | to prevent your application from being downloaded on larger screens, use <a |
| 183 | href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code |
| 184 | <compatible-screens>}</a>, as discussed in the previous section about <a |
| Scott Main | 5e44f68 | 2011-10-07 01:33:09 -0700 | [diff] [blame] | 185 | href="#FilteringHandsetApps">Declaring an App is Only for Handsets</a>.</p> |
| Scott Main | 6aa2b62 | 2011-03-09 14:26:58 -0800 | [diff] [blame] | 186 | |
| 187 | <p>Remember, you should strive to make your application available to as many devices as possible by |
| 188 | applying all necessary techniques for <a |
| 189 | href="{@docRoot}guide/practices/screens_support.html">supporting multiple screens</a>. You should |
| 190 | use <a href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">{@code |
| 191 | <compatible-screens>}</a> or <a |
| 192 | href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code |
| 193 | <supports-screens>}</a> only when you cannot provide compatibility on all screen configurations |
| 194 | or you have decided to provide different versions of your application for different sets of screen |
| 195 | configurations.</p> |
| 196 | |
| Scott Main | 56e1deb | 2011-05-17 18:46:27 -0700 | [diff] [blame] | 197 | |
| 198 | |
| 199 | <h2 id="MultiApks">Publishing Multiple APKs for Different Screens</h2> |
| 200 | |
| Dirk Dougherty | 4d7bc655 | 2012-01-27 17:56:49 -0800 | [diff] [blame] | 201 | <p>Although we recommend that you publish one APK for your application, Google Play allows |
| Scott Main | 56e1deb | 2011-05-17 18:46:27 -0700 | [diff] [blame] | 202 | you to publish multiple APKs for the same |
| 203 | application when each APK supports a different set of screen configurations (as declared in |
| 204 | the manifest file). For example, if you want to publish both a handset version and a tablet |
| 205 | version of your application, but you're unable to make the same APK work for both screen sizes, |
| 206 | you can actually publish two APKs for the same application listing. Depending on each device's |
| Dirk Dougherty | 4d7bc655 | 2012-01-27 17:56:49 -0800 | [diff] [blame] | 207 | screen configuration, Google Play will deliver it the APK that you've declared to support that |
| Scott Main | 56e1deb | 2011-05-17 18:46:27 -0700 | [diff] [blame] | 208 | device's screen.</p> |
| 209 | |
| 210 | <p>Beware, however, that publishing multiple APKs for the same application is |
| 211 | considered an advanced feature and <strong>most applications should publish only one |
| 212 | APK that can support a wide range of device configurations</strong>. Supporting multiple screen |
| 213 | sizes, 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 Dougherty | 4d7bc655 | 2012-01-27 17:56:49 -0800 | [diff] [blame] | 216 | <p>If you need more information about how to publish multiple APKs on Google Play, read <a |
| Dirk Dougherty | 2b286bb | 2012-11-29 17:25:09 -0800 | [diff] [blame] | 217 | href="{@docRoot}google/play/publishing/multiple-apks.html">Multiple APK Support</a>.</p> |