Making Your Application Resolution Independent

If you use the right units and take a little care with your layouts, Android helps your app scale to different screen sizes and different screen densities.

For spacing and layout, it’s best to use dp units. This means that views and margins on the screen will be roughly the same size on devices having different screen densities. They will not be exactly the same size as measured with a ruler, because Android groups screen density and doesn’t use the actual physical screen density. You’ll explore this in more detail later.

For fonts, you should use sp units (scale-independent pixels). sp units act the same as dp units in that sp units are independent of the device’s screen dpi, and they also take ...

Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.