Android: drawable resolutions

前端 未结 6 1553
温柔的废话
温柔的废话 2021-02-08 12:06

I\'ve been through this post (and others) as well as through the documentation about supporting different screen resolutions in Android, but I couldn\'t find a clear answer to a

相关标签:
6条回答
  • 2021-02-08 12:14

    For what it is worth I found the image handling of Android to be tedious and unreliable. The concept of including different size images for different screens will result in large application files bloated with images. There are already screens that don't fit in the standard resolution ranges. I have found it is best not to let android handle the scaling, it seems to create a base image for the smallest screen you target and then scale it up resulting in ordinary looking images on large screens. This happens even if you made the image specifically for the large screen. My solution that seems to work on everything from a 2" samsung phone to a Sony Tablet is to create images at high resolution and use Bitmap.createScaledBitmap() to get the size I need.

    caveat: I am new to Android and have lots to learn.

    0 讨论(0)
  • 2021-02-08 12:22

    Not a complete answer, but: highly downscaled images can and usually do look just as bad as upscaled images (but in a different way), because graphics libraries almost exclusively use interpolation methods for resizing, and interpolation methods are limited in terms of how much they can shrink an image before serious information loss (to about 50% for linear methods and down to about 25% for bicubic methods). This is why most platforms have evolved conventions (like hdpi, mdpi etc.) that let you embed images that are best for each screen size.

    0 讨论(0)
  • 2021-02-08 12:26

    res/drawable is the fallback

    the caveat is that scaling not only degrades the image but takes processing time too.

    I have not even read the API-Level 3 docs yet, sorry for 1/2 an answer

    0 讨论(0)
  • 2021-02-08 12:31

    The images in the drawables folder are assumed to be at mdpi resolution, so they will get scaled up/down if you don't provide the others.

    Scaled up images will be low-resolution and look fuzzy. Scaled down images will have pixels missing and look jaggy.

    So your app will "work" with only one set of default images, but will look awful on many devices. I strongly advise that you create the images in different sizes, so it looks great on all devices - it's a bit boring, but not hard to do.

    It won't be long before we have xhdpi devices, so while you're at it you may want to create those too.

    I assume you've read this

    0 讨论(0)
  • 2021-02-08 12:36

    I use drawable/ all the time, and then I go to BestBuy and all the local wireless stores and test my apps on small/large/huge(tablet) devices and they look just fine.

    0 讨论(0)
  • 2021-02-08 12:36

    Unless you have some reason to target pre-Donut devices (now only 4% of the devices according to http://developer.android.com/resources/dashboard/platform-versions.html), then you should put your bitmaps in one of the -Xdpi directories. The generic "drawable" directory is a synonym of "drawable-mdpi" for compatibility reasons, but a modern well-written app should be putting its drawables in a directory matching the density they are designed for.

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