0
votes

I've looked through the official tutorial and the blog entry on supporting multiple screens. Correct me if I'm wrong - this separation is all about device sizes. If so - could you elucidate why the bucket modifiers(small, normal, large, xlarge) are related to "dp" units:

xlarge screens are at least 960dp x 720dp

large screens are at least 640dp x 480dp

So, "dp" is amount of pixels on a given physical square - inch square if I'm not mistaken. Hence, isn't it possible that a handset device will ever contain amount of pixels equal to density denoted by xlarge bucket - 960dp x 720dp. I mean - if dp is converted into pixels - there might be a device with size of a handset and resolution equal to amount of pixels contained in 960dp and as a result the template that is dedicated for tablets would be picked instead of handset one.

Thanks.

2
right, but under handsets I mean normal smart-phones. So, if one contains the denoted amount he would render the wrong template.midnight

2 Answers

0
votes

Screens are not just big or small but have be described in more physical way with use of pixels and density, so to be able to categorize any screen as large or normal you have to 'normalize' all these hardware parameters. And dp serves this purpose just perfect. If you just needs to know if screen is bigger than normal but exact pixels or density is out your interest, you use this bucked. If you care about pixels or densities, you use other modifiers. It's just matter of what you need, and it is good to be able to have so many options to choose from.

0
votes

The dp unit doesn't say how many pixels something is, but instead it say how many inch/mm something is.

The documentation say that you can convert dp to pixels using this formula:

px = dp * (dpi / 160)

To get dp instead of pixels you can rewrite the expression as follows:

dp = px / (dpi * 160)

If you just take a look at the units in this forula you get:

dp = pixels / (pixels / inch) <==> dp = (pixels / pixels) * inch

Here you can see that the unit for dp is actually inch. 160 dp is also about 1 inch so when you have a bucket of size 960 dp x 720 dp it's actually the same as 6 inch x 4,5 inch.

So regardless of what resolution a phone with 3 inch wide screen have the screen will stay at 3 inch and never become 6 inch, it's just the dpi of the screen that changes. So it is impossible for a phone to get put in the wrong screen size bucket.