Android: only use xxhdpi images

2019-04-04 00:09发布

Is there any drawback in only using xxhdpi images and letting android scale the images? (Yes it might be more cpu intensive, but is it notable?) I tested it on a samsung s2 and the difference were small.

Is there a restriction to only use this if set minSdk to XX, becaus there were no xxhdpi?

4条回答
我只想做你的唯一
2楼-- · 2019-04-04 00:44

In addition to Stephane answer I must say that an image quality would be bad especially on mdpi devices.

查看更多
何必那么认真
3楼-- · 2019-04-04 00:46

I'm not so sure there is going to be an image quality difference: even if you do provide the different versions of the graphic, they're likely just downscales of the original anyway. I'm willing to bet the difference between doing it at run-time and design-time is not going to be significant enough for a user to notice on a mobile phone screen.

I'm also not sure about a performance difference - however, even you admit that there is likely to be a non-zero negative impact. Given that fact, I think it's worth asking "Why not provide pre-scaled graphics?" There are tools (like the Android Asset Studio Icon Generator) that bring the level of effort required to make that happen almost to 0.

In mobile, any deal where you trade nearly 0 work for any potential performance enhancement is a deal you should take.

查看更多
叛逆
4楼-- · 2019-04-04 00:48

Here are a couple drawbacks I can think of:

  • More CPU intensive to resize the images, the app will use more battery and might feel more sluggish, especially on older devices.
  • The images that you are going to load will be bigger and will use more memory. On mdpi/hdpi devices, the VM in which your app run will only have a smaller amount of heap memory available, and you might run into Out Of Memory Exceptions much more frequently if you only load high quality images.
  • The quality of the image might not be as good on mdpi/hdpi devices, because of the resizing. This really depends on what image you are loading, but images with sharp lines might appear a little blurred. But I also want to point out that this only applies if you are really making pngs for each size from a vector graphic. If you are just resizing your xxhdpi png into smaller one, you're probably doing the exact same thing that android is doing on the fly, so there will be no difference at all.
查看更多
霸刀☆藐视天下
5楼-- · 2019-04-04 01:00

Yes, drawable xxhdpi was introduced in API 19. If you want to run your app in a lower API level, you wont get any image because the system can't access the xxhdpi drawables.

This is also true if you only use only xhdpi with Android 2.3.

查看更多
登录 后发表回答