Density is usually specified in pixels per inch or pixels per centimeter (you'll sometimes also hear dots per inch, which is not technically exact). The Nexus One has a 480! 800-pixel screen with a physical size of 8! 4.8 centimeters. The HTC Hero has a 320! 480-pixel screen with a physical size of 6.5! 4.5 centimeters. That's 100 pixels per centimeter on both axes on the Nexus One, and roughly 71 pixels per centimeter on both axes on the Hero. We can calculate the pixels per centimeter easily like this:

pixels per centimeter (on x-axis) = width in pixels / width in centimeters or this:

pixels per centimeter (on y-axis) = height in pixels / height in centimeters

Usually we only need to calculate this on a single axis, as the physical pixels are square (well, they're actually three pixels, but we'll just ignore that here).

How big would our 100! 100-pixel rectangle be in centimeters? On the Nexus One we'd have a 1 ! 1 -centimeter rectangle, while on the Hero we'd have a 1.4! 1.4-centimeter rectangle. That's something we would need to account for if we had, for example, things like buttons that should be big enough for the average thumb on all screen sizes. However, while this example makes it look like this issue could present a huge problem, it usually doesn't. We just need to make sure that our buttons have a good size on high-density screens (e.g., the Nexus One). They will automatically be big enough on lower-density screens.

Was this article helpful?

0 0

Post a comment