Reputation: 8271
I'm writing some code that needs to draw some Canvas class drawing primitives consistently on devices with many different DPI's and screen resolutions. But I can't seem to find what units the drawLine() method's points are in.
It doesn't say in the canvas class documentation: http://developer.android.com/reference/android/graphics/Canvas.html#drawLine(float, float, float, float, android.graphics.Paint)
On S.O. This poster thinks it's in px: how to draw lines with drawLine method in multiple density screens
... and the answerer to this S.O. question did some experiments and determined that the units varied according to a setting in the manifest!
I also looked in Google's Canvas and Drawables documentation and the word "units" doesn't even appear there.
What units are the canvas drawing primitives like drawLine() in and where does Google/Android officially document this?
Upvotes: 2
Views: 2023
Reputation: 38098
It's pixels. As with all the Canvas graphical functions (drawXYZ()
).
Reference: http://developer.android.com/reference/android/graphics/Canvas.html
Mostly because it's all about drawing on a Bitmap.
And a Bitmap measure unit is the pixel.
Upvotes: 3