Is it easier to supply one high-resolution PNG resource and let Android scale it?

I'm looking to create a background image for a view group in an Android app, and I'm not sure what is the best thing to do with this asset.

Is it easier to read (looks better on most phones) to just provide an asset like 900x570 or there, and let Android scale it up and down automatically or scale it on its own in Photoshop and provide these images in 3 drawable-ldpi, drawable-mdpiand drawable-hdpi?

The space savings will be so small: about 10-20 thousand, it makes more sense to me to just let Android scale the images themselves.

The target API will be 2.0 up, and tablets are not supported for starters.

+5
source share
3 answers

Obviously, from a developer’s point of view, it’s clear that Android scales images for you, but on most phones it doesn’t look better. Photoshop has better scaling algorithms than in my experience.

+6
source

if you specify only one image with a copy in any of the drawn, drawable-ldpi, drawable-mdpi and drawable-hdpi, android will scale it for you by default

however, it is good practice to place images of different sizes for performance reasons.

+1
source

, .

, script / / , ... ...

Here is an example of using ImageMagick for my pdf wizard icons and eye candy lists:

#!/bin/bash
convert -transparent white ic_padlock.pdf ic_padlock.png
convert -scale 36x36 ic_padlock.png ../../res/drawable-ldpi/ic_launcher_padlock.png
convert -scale 48x48 ic_padlock.png ../../res/drawable-mdpi/ic_launcher_padlock.png
convert -scale 72x72 ic_padlock.png ../../res/drawable-hdpi/ic_launcher_padlock.png
convert -scale 24x24 ic_padlock.png ../../res/drawable-ldpi/ic_listview_padlock.png
convert -scale 32x32 ic_padlock.png ../../res/drawable-mdpi/ic_listview_padlock.png
convert -scale 48x48 ic_padlock.png ../../res/drawable-hdpi/ic_listview_padlock.png
convert -transparent white ic_padlock_ok.pdf ic_padlock_ok.png
convert -scale 36x36 ic_padlock_ok.png ../../res/drawable-ldpi/ic_listview_padlock_ok.png
convert -scale 48x48 ic_padlock_ok.png ../../res/drawable-mdpi/ic_listview_padlock_ok.png
convert -scale 72x72 ic_padlock_ok.png ../../res/drawable-hdpi/ic_listview_padlock_ok.png

You can use the conversion with a density parameter for best rendering:

convert -density targetdensityxtargetdensity  -transparent white splash.pdf ../../res/drawable/splash.png
+1
source

All Articles