Blog Archive

Android Units of Measurements - Difference between px, in, mm, dp, dip and sp

Explanation of various Android units of measurements px, in, mm, dp, dip and sp


Web designers have always designed web pages in pixels. The problem with pixels is that with increased screen resolutions the, with more dots for inch, the display content such as text and images become smaller and smaller. And with so many devices today with varied resolutions it becomes harder for designers to design the best interface suited for all of them. Here comes the dip and sp to rescue for android programmers.

Android supports the following measurements:


  • px (Pixels) - Actual pixels or dots on the screen.
  • in (Inches) - Physical size of the screen in inches.
  • mm (Millimeters) - Physical size of the screen in millimeters.
  • pt (Points) - 1/72 of an inch.
  • dp (Density-independent Pixels) - 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. "dip" and "dp" are same.
  • sp (Scale-independent Pixels) - Similar to dp unit, but also scaled by the user's font size preference.

TIP: Always use sp for font sizes and dip for everything else.

Here is a quick checklist about how you can ensure that your application displays properly on different screens:

  1. Use wrap_content, fill_parent, or dp units when specifying dimensions in an XML layout file
  2. Do not use hard coded pixel values in your application code
  3. Do not use AbsoluteLayout (it's deprecated)
  4. Supply alternative bitmap drawables for different screen densities