I am trying to make an app using canvas and a surfaceview, and I am worrying that in the future I would have many problems with it because I am not sure if the canvas is proportional with every device. currently I can only use my emulator since my phone’s usb cable doesn’t work(I know.. I have to get a new one..).
anyways, i would like to know if the canvas would transfer my coordinates and make everything proportional, what I mean by that is that if i have something in point a, lets say (10, 10) on a device that the screen of it is 100 X 100 (this is just an example for easy calculation) it would be on point (1, 1) on a 10 X 10 device.
This is really bothering me…
Thanks!
No, this wouldn’t be the case. If you have a coordinate (10,10), it would be the same on all devices. I’d suggest you
scaleyour drawings.To
scaleyour drawings you simply define a bitmap (that will stay the same) you’d like to draw to (when screen sizes change, that bitmap will be stretched).Define a constant bitmap:
Get the scale for both x and y
Define a canvas object based on the bitmap you defined earlier on (allowing you to draw to it eg. canvas.drawRect() […]):
In your rendering Thread you’ll have to have a Canvas called frameBuffer, which will render the virtual framebuffer: