How does pixel density correspond to screen size?

696 Views Asked by At

Sorry for creating a potential duplicate but I haven't found anything that answers my question. It essentially boils down to:

What image sizes should I include in which folders for full screen images to support all Android devices?

Answers usually state different pixel resolutions to put in each of the density buckets.

For example:

xxxhdpi: 1280x1920 px
xxhdpi: 960x1600 px
xhdpi: 640x960 px
hdpi: 480x800 px
mdpi: 320x480 px
ldpi: 240x320 px

Source: Android: Background Image Size (in Pixel) which Support All Devices

A list like this is actually exactly what I was looking for. The only problem is that it doesn't make sense to me.

Grouping images by density seems right for images which are supposed to be displayed the same size across different densities (e.g. to have an icon always at the size of 1 x 1 cm, independent on the screen density).


However when it comes to full screen images I don't want to pick an image based on the display's pixel density but based on its actual pixel size! (Or do I?)

Lets say I have 3 devices (fictional values):

  • 2" watch with 500 x 500px display (~hdpi)
  • 4" phone with 1000 x 1000px display (~hdpi)
  • 10" tablet with 1000 x 1000px display (~mdpi)

And a 1000 x 1000px image which I want to display full screen on all devices.

Obviously the 2" & 4"-devices have a higher pixel density, so they get the image from the hdpi-bucket, while the 10"-device gets it from the mdpi-bucket. This means that the 2" & 4"-devices use the same image size, while the 10"-device uses a smaller one.

But my intuition tells me that I should use a scaled down image for the 2"-device (not enough pixels to display the 1000 x 1000px image), and the full resolution for the 4" & 10"-devices (since both of them have enough pixels to benefit from the full resolution of 1000 x 1000px). It seems to me that the density buckets are unsuitable to achieve this.


I'm assuming that the answers out there aren't all wrong and that its just my thought process which is flawed. I just can't figure out at what point. Any help appreciated!

Ps. I'm not worried so much about precise resolution values or aspect-ratios. Some cropping / stretching is totally fine. I'm just wondering how to make Android pick the image with the most suitable resolution when you want to display it full screen. The density buckets seem to me not to be the right approach.

1

There are 1 best solutions below

2
On

What image sizes should I include in which folders for full screen images to support all Android devices?

There is, essentially, no answer to your question.

In general, pixel density and screen size can be correlated, but there's no formal relationship between the two. There's nothing stopping some hardware manufacturer from making a tiny device with incredibly high pixel density or a huge device with low pixel density.

Additionally, there are plenty of examples of different devices with identical pixel densities but wildly different screen sizes.

Finally, there's the question of aspect ratio: you could have two devices with the same pixel density and the same number of horizontal pixels... but they could easily have two different numbers of vertical pixels.

Any attempt to create a "full screen" png that works on every single Android device is destined to fail (at least in some ways) on at least some devices. You could create vector drawables that scale to any screen size, but you'd still need to live with the fact that there are screens of different aspect ratios.