Size of a Canvas in a Surfaceview against real screen resolution

人盡茶涼 提交于 2019-12-24 08:07:51

问题


I am trying to use the SurfaceView and the Canvas to make some draws, in my 480x800 phone, but I do not understand how this is managed, because when I display canvas size, it show 320x533 ( while my screen is 480x800 )

I tryied to use setFixedSize() on the getHolder to reset the canvas resolution, seems to work fine, but is it a correct way to do such resize ?

Another trouble is getting the touch event coordinates, while my canvas seem to be resized, to touch events are still matched against a 320x533 screen, how can I change that ?


回答1:


Your application is running in compatibility mode. You must either target the proper API level or declare in your manifest that you support multiple densities.



来源:https://stackoverflow.com/questions/8013922/size-of-a-canvas-in-a-surfaceview-against-real-screen-resolution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!