Game Development Reference
In-Depth Information
Handling Different Screen Sizes and Resolutions
Android has supported different screen resolutions since version 1.6. It can handle resolutions
ranging from 240×320 pixels to a full HDTV resolution of 1920×1080. In Chapter 4, we discussed
the effect of different screen resolutions and physical screen sizes. For instance, drawing with
absolute coordinates and sizes given in pixels will produce unexpected results. Figure 5-1 shows
what happens when we render a 100×100-pixel rectangle with the upper-left corner at (219,379)
on 480×800 and 320×480 screens.
Figure 5-1. A 100×100-pixel rectangle drawn at (219,379) on a 480×800 screen (left) and a 320×480 screen (right)
This difference is problematic for two reasons. First, we can't draw our game and assume a fixed
resolution. The second reason is more subtle: in Figure 5-1 , we assumed that both screens have
the same density (that is, each pixel has the same physical size on both devices), but this is
rarely the case in reality.
Density
Density is usually specified in pixels per inch or pixels per centimeter (sometimes you'll hear
about dots per inch, which is not technically correct). The Nexus One has a 480×800-pixel
screen with a physical size of 8×4.8 centimeters. The older HTC Hero has a 320×480-pixel
 
Search WWH ::




Custom Search