Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do dp, dip, dpi, ppi, pixels and inches relate?

I was reading dp, dip, px, sp measurements, but I still have some questions about dp/dpi vs ppi vs px vs inch. I am not able to compare them... is an inch the largest?

They say 160 dpi means 160 pixels per one inch. Does that mean 1 inch contains 160 pixels?

They also say 1 pixel on a 160 dpi screen = 1 dp. Does that mean 1 pixel and 1 dp are equal?

And lastly, why should we use dp instead of px? I understand that it is ideal, but why?

like image 608
Chandeep Avatar asked Dec 12 '11 18:12

Chandeep


People also ask

Is DPI same as pixels per inch?

DPI refers to the number of printed dots contained within one inch of an image printed by a printer. PPI refers to the number of pixels contained within one inch of an image displayed on a computer monitor.

Is 300 DPI the same as pixels per inch?

Image size is expressed as DPI (dots per inch) and PPI (pixels per inch). So, when you ask yourself, “what is 300 DPI in Pixels Per Inch per image,” the answer is 300 because 300 DPI in an image means there are 300 pixels per inch in your web design image.

What is 72 dpi in pixels per inch?

Pixel density So, if you see 72 dpi it means that the image will have 72 pixels per inch; if you see 300 dpi means 300 pixels per inch, and so on. The final size of your image depends on the resolution that you choose.

Is dp equal to pixel?

A dp is equal to one physical pixel on a screen with a density of 160. To calculate dp: dp = (width in pixels *... A dp is equal to one physical pixel on a screen with a density of 160.


1 Answers

You should (almost) always use flexible sizing units, like dp, which is Density-Independent Pixels, because 300px on one device is not necessarily the same amount of screen real estate as 300px on another. The biggest practical implication is that your layout would look significantly different on devices with a different density than the one your design targeted.

  • dp or dip means Density-independent Pixels
  • dpi or ppi means Dots (or Pixels) Per Inch
  • inch is a physical measurement connected to actual screen size
  • px means Pixels — a pixel fills an arbitrary amount of screen area depending on density.

For example, on a 160dpi screen, 1dp == 1px == 1/160in, but on a 240dpi screen, 1dp == 1.5px. So no, 1dp != 1px. There is exactly one case when 1dp == 1px, and that's on a 160dpi screen. Physical measurement units like inches should never be part of your design—that is, unless you're making a ruler.

A simple formula for determining how many pixels 1dp works out to is px = dp * (dpi / 160).

like image 66
Chris Cashwell Avatar answered Sep 20 '22 23:09

Chris Cashwell