Auto-scaling works fine on phone screens, but not tablets?
I'm writing a game for Android and I'm having a problem with bitmap auto-scaling.
My phone is a Motorola Droid, and it works fine on it. When I run an AVD with a similar resolution to my phone running 2.2 it runs fine, and if I run an AVD with a smaller (320x240) screen and AndroidOS 1.6, it properly scales the bitmaps down and 开发者_Python百科it looks just fine.
But when I run it on an AVD running 3.0 and a large screen (emulating a tablet), the bitmaps don't scale up at all. My code finds the location of where to draw everything based on the screen's height, so everything is drawn in the right location, just without the bitmap being scaled.
The problem is, if I write code to scale the bitmaps based on the screen's height, then when I run it on the AVD with a small screen, then it ends up being tiny because it gets scaled down TWICE - once by my own code, and once by the auto-scaling code.
Any help?
I feel like a noob. The answer to my problem was to just change the way I was drawing to the screen. I'm using Canvas.DrawBitmap, but I was using the version that passes just an x and y point on the screen, which lets the auto-scaler handle scaling. I switch to the version that uses a Rect for the destination which allows me to specify exactly where on the screen my graphic gets drawn, including height/width.
In the manifest, if the targetSdkVersion
isn't set to at least 11, then the app will run in compatibility mode. Is this your issue?
精彩评论