简体   繁体   中英

Android - Supporting Different Screens

I'm programming for a little game in android, but i'm stuck at understanding how the scaling of drawables work or should be done.

I'm drawing a Tilemap in a View on a Canvas with Canvas.drawBitmap()

Main problem is that i don't know how i should manage bitmaps to occupy the same space independent of screen resolution.

My Tile is 64x64 png file and it's placed in drawables folder. Then if i want it to occupy the same space in a xxhdpi screen what should i do?

Should i place in drawables-xxhdpi folder the same tile but as a 192x192 file? Or should i convert px to dps for the drawBitmap() method? Or is there something else?

I'm getting really confused trying out things, and i see myself not getting anywhere.

Thanks in advance!

You're right. You should keep a bitmap file with different resolutions in different drawables folder. That allows the application to fetch the required files automatically on the basis of the size of device the user uses.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM