简体   繁体   English

Android-支持不同的屏幕

[英]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. 我正在为android中的一个小游戏编程,但我坚持了解可绘制对象的缩放是如何工作或应该完成的。

I'm drawing a Tilemap in a View on a Canvas with Canvas.drawBitmap() 我正在使用Canvas.drawBitmap()在画布上的视图中绘制Tilemap

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. 我的图块是64x64 png文件,放置在drawables文件夹中。 Then if i want it to occupy the same space in a xxhdpi screen what should i do? 然后,如果我希望它在xxhdpi屏幕中占据相同的空间,该怎么办?

Should i place in drawables-xxhdpi folder the same tile but as a 192x192 file? 我应该将192x192文件放置在drawables-xxhdpi文件夹中的同一图块中吗? Or should i convert px to dps for the drawBitmap() method? 还是应该为drawBitmap()方法将px转换为dps? 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. 您应该在不同的drawables文件夹中保留具有不同分辨率的位图文件。 That allows the application to fetch the required files automatically on the basis of the size of device the user uses. 这使应用程序可以根据用户使用的设备大小自动获取所需的文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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