0
votes

I cannot find the answer to this question anywhere on or off stack overflow:

Google defines common sizes and densities for devices as follows:

Common dimensions (in inches) and densities.

Sizes:

  • xlarge screens are at least 960dp x 720dp
  • large screens are at least 640dp x 480dp
  • normal screens are at least 470dp x 320dp
  • small screens are at least 426dp x 320dp

Densities:

  • ldpi (low) ~120dpi
  • mdpi (medium) ~160dpi
  • hdpi (high) ~240dpi
  • xhdpi (extra-high) ~320dpi
  • xxhdpi (extra-extra-high) ~480dpi
  • xxxhdpi (extra-extra-extra-high) ~640dpi

My question is:

Which of these sizes corresponds to mobile phone devices? None of the sizes are portrait (height > width).

Say you are trying to figure out what dp to make a full screen bitmap to accommodate all mobile devices...

3

3 Answers

1
votes

Generalizing a lot:
For phones (in portrait mode, width by height)

ldpi    was typically 240 by 320  
mdpi    was typically 320 by 480  
hdpi    is typically 480 by 800 or 480 by 854 and lately 540 by 960
xhdpi   is typically 720 by 1280 or 800 by 1280  
xxhdpi  is typically 1080 by 1920  
xxxhdpi is typically ? by ? // who knows that? Feel free to edit, if absolutely sure. 

For tablets, it's totally different.
But you asked for phones only.

1
votes

You can't make best bitmap for all devices. Many manufacturer set density via build.prop file ro.sf.lcd_density so tablet could act like phone.

It's better to get current device values with getResources().getDisplayMetrics() and go with it. You can set ImageView as background and continue with cropping options: ImageView.ScaleType

0
votes

After reading the Supporting Multiple Screens Android documentation several times over, and brainstorming a lot, I believe I have identified a couple of ways Google would like developers to generally go about this.

Legacy Solution:

Primarily, they wanted developers to use these small, normal, large, xlarge size qualifiers for drawable/ resource directories to allow Android to pick the correct resource to use.

I think the important thing to notice here, and I could be wrong, is that maybe they originally didn't want developers to have worry about whether the dimensions for these small, normal, large, xlarge sizes apply to a phone or tablet, but rather know they apply to both.

The caveat with that, of course, is that a full-screen image with landscape dimensions (width > height) will not look the same on a portrait device (height > width).

The solution using the legacy method would be to use an ImageView and set it's ScaleType appropriately, so it crops your tablet-sized image on mobile devices.

But there is another possible solution...

Alternate Solution:

There is a also a section on "New Qualifiers" for supporting different screen configurations. In this section, Google details qualifiers such as smallestWidth or available width, that could in theory, be used on your drawable/ resource directories to define proper portrait or landscape resources for your available device width.

For those familiar with web development, these qualifiers are the equivalent of CSS media queries.

As for specific widths to use, Google details some typical configuration examples:

  • 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
  • 480dp: a tweener tablet like the Streak (480x800 mdpi).
  • 600dp: a 7” tablet (600x1024 mdpi).
  • 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).

The only doubt left in my mind is that all of their examples use these qualifiers for layout, but not drawable resources. It begs the question whether this is the defacto solution they want developers to use for the given problem.