tags:

views:

68

answers:

2

I'm confused about how to write resolution independent code for an Android game and I'm looking for some concise tips and guidelines as I'm never sure what to do about the multiple versions of Android. Here's what I specifically want to do:

Can someone explain what I would do in the above situation to get the results I want?

The things I'm specifically confused about are:

  • How does API1.6 pick which folder (e.g. -hdpi) to load a bitmap from and how does it decide what to scale it by?
  • Does API 1.5 have some kind of auto scaling feature? The width and height reported by the canvas seems to be scaled by the screen density.
A: 

Can anyone help? :-/

ScalerScale
A: 

I think this page should help: http://developer.android.com/guide/practices/screens_support.html

1.5 doesn't do scaling because all devices at the time of 1.5 launch were mdpi.

For 1.6 and above Android decides which res directory to pull from based on a runtime determination of the screen's dpi and then scales assets appropriately.

So if you put your 100x100 bitmap in res/drawable and then run your app on an hdpi device, Android will first look for the bitmap in res/drawable-hdpi, when it doesn't find it Android will scale up the resource you have in res/drawable.

Richard