I’m making an app for 1.6 and I’m having a problem with android image scaling, I have a picture that’s 480×295.
On a medium screen this appears correctly, but on a large screen (480×800 or 480×854) it doesn’t fill the screen, it android makes the image 1.5x bigger, which is only 720×442.
As 800 is actually 1.67 and 854 is 1.78, I can obviously just include large images for the drawable-hdpi folder, but the image is already 1.5mb, which is larger than people seem to like, and I can’t use app2sd as I want to support 1.6.
Any suggestions?
I can only think of three options:
1) Include the larger images (but that limits sales probably, and obviously increases the apk size)
2) Make 2 versions, seems a good solution, just harder to implement.
3) Change to 1.5, and handle all my scaling myself.
EDIT:
More details:
I’m drawing using canvas and surfaceview
Image loading code:
backgroundBMP = BitmapFactory.decodeResource(getResources(), R.drawable.background, null);
And the drawing code:
canvas.drawBitmap(backgroundBMP, 0, 0, null);
If you wanna scale your
Bitmapyou can do that by usingcanvas.scale(scaleX, scaleY);beforecanvas.drawBitmap(). You could calculate the aspect ratio and use that as your scale value.One important thing to add is that you can use the “Move to SD card” feature using
<uses-sdk android:minSdkVersion="3" />and still support lower Android versions, specified byminSdkVersion.