Confused about scaling Bitmap with support for different resolutions in Android

I am confused about how to write resolution-independent code for an Android game, and I'm looking for a few quick tips and tricks, as I'm never sure what to do with multiple versions of Android. Here is what I specifically want to do:

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

What particularly bothers me is:

  • How does API1.6 choose which folder (for example, -hdpi) to load the bitmap image and how does it decide what to scale it to?
  • Does API 1.5 have some sort of auto-scaling feature? The width and height reported by the canvas seem to scale according to the density of the screen.
+3
source share
1 answer

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

1.5 does not scale, because all devices at the time of launching 1.5 were mdpi.

1.6 Android , res , .

, 100x100 res/drawable, hdpi, Android res/drawable-hdpi, , Android , res/drawable.

+1

Source: https://habr.com/ru/post/1759534/


All Articles