77

according to http://developer.android.com/training/multiscreen/screendensities.html

The following scale factors are mentioned

xhdpi: 2.0 hdpi: 1.5 mdpi: 1.0 (baseline) ldpi: 0.75

I was wondering what the scale factor would be for xxhdpi?

Jonik
  • 80,077
  • 70
  • 264
  • 372
Muhammad Ahmed AbuTalib
  • 4,080
  • 4
  • 36
  • 59
  • Does it even support xxhdpi? Not like Google to miss something out of the docs – musefan Sep 06 '13 at 10:10
  • @musefan , android sdk creates a folder automatically since the start of this year atleast , called drawable-xxhdpi . Also S4 , HTC ONE , and Xperia Z are xxhdpi . I have seen them take resources from the xxhdpi bucket . they are way above the xhdpi (240) level – Muhammad Ahmed AbuTalib Sep 06 '13 at 10:13
  • see my answer [here too](http://stackoverflow.com/questions/36820746/how-to-design-any-screen-size-and-density-in-androidmulti-screen-for-mobiles/36821546#36821546) – mehrdad khosravi Jul 27 '16 at 07:10

2 Answers2

284

In android.util.DisplayMetrics, you can see that scaling factor is 0.00625:

/**
 * Scaling factor to convert a density in DPI units to the density scale.
 * @hide
 */
public static final float DENSITY_DEFAULT_SCALE = 1.0f / DENSITY_DEFAULT;

Where as DENSITY_DEFAULT is 160 --> scaling factor = 1.0f / 160 = 0.00625.

sizeScale = DENSITY_DEFAULT_SCALE * DENSITY_DPI

From this:

  • ldpi = 0.00625 * 120 -> 0.75
  • mdpi = 0.00625 * 160 -> 1.0
  • hdpi = 0.00625 * 240 -> 1.5
  • xhdpi = 0.00625 * 320 -> 2.0
  • xxhdpi = 0.00625 * 480 -> 3.0
  • xxxhdpi = 0.00625 * 640 -> 4.0

Not exactly a rocket science, but hope this will be useful for someone :)

ozbek
  • 20,955
  • 5
  • 61
  • 84
  • 3
    and tvdpi -> 1.3312501 (for example: https://plus.google.com/105051985738280261832/posts/6eWwQvFGLV8) – Vitaly Zinchenko Oct 20 '15 at 17:32
  • 2
    I wonder if this is still true; the Google Device Metrics site lists both 3.5 and 4.0 scaling for xxxhdpi: https://design.google.com/devices/. I'm not sure how to resolve that inconsistency... – lilbyrdie Apr 25 '16 at 15:10
  • 4
    @lilbyrdie: it does still hold. See the comment for `DENSITY_560` in `android.util.DisplayMetrics` – ozbek Apr 26 '16 at 05:13
  • 1
    @ozbek: So even though the devices might be labelled xxxhdpi, internally they aren't? That also implies _all_ graphics are scaled for them? That doesn't sound very efficient. I also see that there are _four_ other intermediate densities... In any case, thanks for the info. That's exactly what I was looking for. – lilbyrdie Apr 27 '16 at 18:57
  • xxxhdpi is only used for launcher icons anyway. See https://developer.android.com/guide/practices/screens_support.html#xxxhdpi-note – the_new_mr May 02 '17 at 12:18
  • @the_new_mr well, Google does not seem to follow that guideline themselves though. Almost all of their apps have non-launcher-icon images under xxxhdpi folders. – ozbek May 03 '17 at 11:56
  • 2
    @ozbek Really? That's insane. Perhaps we shouldn't be surprised. It's buried so deep in the documentation that even the Google developers themselves probably don't know it :) – the_new_mr May 03 '17 at 17:44
  • @the_new_mr - that makes no sense, nor is it what docs say anywhere that I've seen [though perhaps the docs hadn't been updated properly for xxxhdpi, when you wrote your answer!]. xxxhdpi is for *all* resources, on a device that says it is 640 dpi. – ToolmakerSteve Jan 31 '19 at 01:38
  • @ozbek - FWIW, I found the use of `0.00625 *` in your list of densities confusing. Wouldn't it be simpler to do `nnn / 160`? Then it would be immediately obvious why "320 / 160" -> "2.0". :) – ToolmakerSteve Jan 31 '19 at 01:43
  • @lilbyrdie - ".. all graphics are scaled for them?". Not necessarily. The declared density is a *logical* density. For example, if a phone's actual, physical density was 163 dpi, it would be terrible to have to scale all images to that exact, true, density. Result would look bad. Instead, a phone picks a nice, round, number. Its as if the phone was physically slightly larger, or slightly smaller, such that the density becomes a simple round number. This means that if you draw a "1 inch" square on different phones, you'll find its size varies on each model. But images will be clean. – ToolmakerSteve Jan 31 '19 at 02:02
  • BTW, the newer "in-between" display densities are: 420dpi / 160 -> "2.625" multiplier, and 560dpi / 160 -> "3.5" multiplier. – ToolmakerSteve Jan 31 '19 at 02:15
6

If you look at Metrics and Grids you'll see that xxhdpi is 480 dpi which is 3 times that of the baseline (mdpi @ 1.0). In other words the scale factor for xxhdpi is 3.0

Squonk
  • 48,735
  • 19
  • 103
  • 135