This is the first part of a several part series on handling multiple screen sizes in your Android projects. This material is adapted from a chapter in The Busy Coder’s Guide to Android Development, Version 3.0.
For the first year or so since Android 1.0 was released, all production Android devices had the same screen resolution (HVGA, 320×480) and size (around 3.5″ / 9cm). Starting in the fall of 2009, though, devices have been arriving with widely disparate screen sizes and resolutions, from tiny QVGA (240×320) screens to much larger WVGA (480×800) screens.
Of course, users will be expecting your application to be functional on all of these, and perhaps take advantage of larger screen sizes to add greater value. To that end, Android 1.6 added new capabilities to help better support these differing screen sizes and resolutions.
The Android documentation has extensive coverage of the mechanics of handling multiple screen sizes. These blog posts are designed to complement that coverage.
Let’s suppose, though, that you start off by totally ignoring the issue of screen sizes and resolutions. What happens?
If your application is compiled for Android 1.5 or lower, Android will assume your application was designed to look good on the classic screen size and resolution. Android will then automatically do the following:
- If your application is installed on a device with a larger screen, Android will run your application in “compatibility mode”, scaling everything based on the actual screen size. So, suppose you have a 24px square PNG file, and Android install and runs your application on a device with the standard physical size but a WVGA resolution (a so-called “high-density” screen). Android might scale your PNG file to be 36px when it displays it, so it will take up the same visible space on the screen. On the plus side, Android handles this automatically; on the minus side, bitmap scaling algorithms tend to make the images a bit fuzzy.
- Android will block your application from running on a device with a smaller screen. Hence, QVGA devices, like the HTC Tattoo, will be unable to get your application, even if it is available on the Android Market.
If your application is compiled for Android 1.6 or higher, Android assumes that you are properly handling all screen sizes, and therefore will not run your application in “compatibility mode”.
The next post in the series will begin providing tips for how to design layouts that will work independent of resolution.