Do we need to add all images with different dpi to Android Apps

后端 未结 1 1927
无人共我
无人共我 2021-01-18 21:17

As you know Android applications have different DPIs and also in the Android applications we can add drawables with diffrent DPIs in diffrent ldpi,

相关标签:
1条回答
  • 2021-01-18 21:51

    TLDR see the bold below

    Different density folders were added later on for Android which means that...

    If you wanted to be lazy and just add one asset the best choice would probably be the HDPI asset if your min app target < 8 and XHDPI if its >= 8. This is because the system will scale the resource up and down, but you would still want to start off with the highest resolution possible.

    If you want to have complete control over how the assets are scaled then you can by all means provide your own for all / some of the densitys. In practise I generally provide HDPI / XHDPI as above and give all the resource buckets for things like logos / AB icons / App icons etc. I generally find the auto scaling to be pretty good and work for most situations, but will occasionally have to supply and extra LD/MD asset if its a small asset / contains small text etc. Plus if i duplicated all assets for things like XXXHDPI I would get pretty good apk bloat.

    You can also use IDEs built in tools to add a single asset for many densitys at once. In Android Studio 0.6 this is File->New->Image Asset and a wizard will appear.

    I have never noticed or heard of any perfomance impact of allowing Android to scale assets automatically - presumably this is done in hardware.

    It may not look great when auto scaling down to LDPI say so you can optionally provide your own scaled assets for all other densities.

    Taken from the link below

    • ldpi: Low-density screens; approximately 120dpi.
    • mdpi: Medium-density (on traditional HVGA) screens; approximately 160dpi.
    • hdpi: High-density screens; approximately 240dpi.
    • xhdpi: Extra high-density screens; approximately 320dpi. Added in API Level 8
    • nodpi: This can be used for bitmap resources that you do not want to be scaled to match the device density.
    • tvdpi: Screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a "primary" density group. It is mostly intended for televisions and most apps shouldn't need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. This qualifier was introduced with API level 13.

    List taken from this dev link for more info.

    This is the approach I have used on many apps in my professional career including ones for Google & the BBC and not had issues.

    0 讨论(0)
提交回复
热议问题