28
Apr

Android Units - Difference between Screen Measuring Units

28 Apr
Measuring units. You'd think there's just one. Well, think again!

Here's a list showing you all of them:

-     in
    Full Name: inches
    Description: Takes into consideration the physical screen of the device

-    dp || dpi
    Full Name: Density Independent Pixel
    Description: An abstract unit that is based on the physical density of the screen. These units are relative to a 160 dpi screen, so one dp is one pixel on a 160 dpi screen. The ratio of dp-to-pixel will change with the screen density, but not necessarily in direct proportion.

-     sp || sip
    Full Name: Scale-independent Pixels
    Description: This is like the dp unit, but it is also scaled by the user's font size preference.

-    px
    Full Name: Pixels
    Description: Corresponds to actual pixels on the screen.

-    mm
    Full Name: Millimeters
    Description: Related with the physical size of the screen.

-    pt
    Full Name: Points
    Description: 1/72 of an inch based on the physical size of the screen.

Here's an image to understand more about the units.

Android Units

With this in mind, Android has a set of six generalized densities:

-    ldpi (low) ~120dpi

-    mdpi (medium) ~160dpi

-    hdpi (high) ~240dpi

-    xhdpi (extra-high) ~320dpi

-    xxhdpi (extra-extra-high) ~480dpi

-    xxxhdpi (extra-extra-extra-high) ~640dpi

What's in it for me? You may ask. Just remember this if you're developing on Android: Use dp for layout and sp for fonts. 
Now you're all set, have fun.
 
Leave A Comment