Will a density qualified drawable folder or drawable-nodpi take precedence?

前端 未结 4 675
余生分开走
余生分开走 2020-12-04 18:39

If I define drawables for a density qualified folder (eg drawable-hdpi), and also drawables to fall back on in drawable-nodpi, will a high de

4条回答
  •  [愿得一人]
    2020-12-04 18:53

    drawable-nodpi will bypass scaling and drawable will use the default scaling:

  • mdpi = 1x
  • hdpi = 1.5x
  • xhdpi = 2x
  • xxhdpi = 3x
  • xxxhdpi = 4x

    drawable-nodpi is efficient if your code will be doing its own scaling (or no scaling) and you don't want the image pre-scaled by Android.

    There is also drawable-anydpi, just to make things more confusing.

    drawable with no specifications will be used if an exact match on density and screen specifications does not exist. drawable-nodpi will be used after drawable.

    UPDATE If you have both drawable and drawble-nodpi, the select order is either a more complex rule not documented or Android is broken. Through experimentation I confirmed that devices with screen density < xhdpi will correctly select the drawable image. Devices with screen density >= xhdpi will select the drawable-nodpi.

    Selection rule: 1. Pick match to screen density, one of these:

    • drawable-ldpi
    • drawable-mdpi
    • drawable-hdpi
    • drawable-xhdpi
    • drawable-xxhdpi
    • drawable-xxxhdpi
    1. If no match on density, then select one of these
    • drawable (automatic scaling mdpi=none... xxxhdpi=4x)
    • drawable-nodpi (no scaling)
    • drawable-tvdpi
    • drawable-anydpi (no scaling)

提交回复
热议问题