Question

I'm asking this question after much reading. I've always heard that dpi is for printers, but when it comes to screen now, they are also talking about dpi. Are they referring to ppi?

Now, what is really resolution, for me its the the number of pixels each dimension can display, e.g. 800x600 means 800 pixesl on width and 600 pixels on the height, but at some places I'm seeing that they are referring to resolution as dpi.

I'm trying to understand this concept well because its very important in Android, like in this article,

For example, say an icon is intended to be 0.5x0.5 in when rendered on a screen. Next, the image must be created at the largest density supported, or as a scalable vector graphic. Best practice is to support the maximum density, which currently is xxhdpi at 480 dpi. At 480 dpi, a 0.5x0.5 in image converts to 240x240 px.

So it is referring dpi as ppi actually if I understand?

So far what I've understood is that different pixels may render different number of pixels. This is why we don't use pixels as measurement unit. Instead we use dp, where a dp is one pixel on 160 dpi device (again the confusion about dpi & ppi)

Can someone clear this big confusion or direct me to an article that may clear it

Was it helpful?

Solution

Mate, Resolution being 800 X 600 implies that the screen has 480,000 pixel points that will be used to render the screen(This is often confused with the dimensions of the display). DPI or PPI means dots/points per inch, this is the measure of the density of the screen.

So just given the Resolution, one can not determine the actual length of the display unless the density parameter is also available. So a 800 X 600 resolution has 480,000 Pixel points & a let this device has a density of 480 dpi.

So the Width of the screen

= No of pixel points along its width/Density

= 800/480

= 1.67 inches

Similarly,

Height = 600/480 =1.25 inches

and if 800X600 resolution device has density of 160 dpi, its dimensions will vary drastically. Following calculations calculate Height/Width of 800X600 on 160 dpi. Compare these two values with above 480 dpi calculations.

the Width of the screen = No of pixel points along its width/Density

= 800/160

= 5.0 inches

Similarly,

Height = 600/160 =3.75 inches

This is the very reason that scaling images to best fit the screen is such a complex issue on frafmented android environment.However, I love android!

Hope this helps! and any one who has some thing to add/delete.modify to this answer is most welcome.

OTHER TIPS

  1. dpi (dots per inch) == ppi (pixels per inch)
  2. You are also talking about the DisplayMetrics.density, which gives you the multiplier for the dp unit of measurement.
  3. There's also DisplayMetrics.scaledDensity which also takes into account text size user chose.

To put it plainly, dp unit is intended to give you some security about size of your objects on screen. 160dp should represent one inch on any screen. In order to achieve that, you have to multiply your dimension by DisplayMetrics.density or DisplayMetrics.scaledDensity.

That is, if you're doing that in code. For Layouts, you can just enter a View's dimensions in dp and have Android framework take care of that for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top