Mark
Mark

Reputation: 5566

Android fullscreen image

I'm quite experienced Android developer but I have very easy problem. How to properly make a fullscreen image in Android? Currently I'm using one better quality image and use it on all devices. This works quite ok but downscalling on very small devices looks bad and it can cause an OOM Error.

There were few threads about it, for example:

But in my opinion answers are not right. Everybody says that I should use ldpi, mdpi, hdpi, xhdpi folders and I agree this works for small images (buttons, switches), nine patches, things that you want to have the same physical size on every screen. When it comes to fullscreen this is wrong. My HTC Desire (480x800) is hdpi and my Samsung Galaxy Tab 2 (800x1280) is mdpi. Using above advices would result in Galaxy Tab 2 using smaller images than HTC Desire which is very wrong.

Is there any easy way to solve this fullscreen image problem?

Thanks in advance

Upvotes: 0

Views: 1887

Answers (2)

Stephane Mathis
Stephane Mathis

Reputation: 6612

You should use the small-normal-large-xlarge qualifier. You can even mix multiple qualifier, for instance : drawable-small-hdpi or drawable-small-mdpi and have the right image.

Upvotes: 1

Neil Townsend
Neil Townsend

Reputation: 6084

One option is to determine the screensize yourself (Get screen dimensions in pixels) and then pick which image you use:

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);
int width = size.x;
int height = size.y;

// Stuff
if      (width < /*some number*/)       putLowResFullScreenImage();
else if (width < /* a bigger number*/)  putMidResFullScreenImage();
else                                    putHighResFullScreenImage();

Upvotes: 1

Related Questions