问题描述:

I am trying to write an app for android.

Therefore I've got a SurfaceView class drawing all objects.

Now, when for instance I'm drawing a circle, I have to specify a size.

Is there a way making this size depending on how big the screen resolution and density is?

Becausei when drawing a circle, I want it to be the same size on a lower resolution device as on a high resolution device.

When drawing a circle with 50px radius, it would be bigger on smaller screens than on bigger screens.

Any ideas?

EDIT:

I know when creating some layout i could use density-pixels. But I am not working on layouts, i am drawing on top of a surfaceview. when drawing something like

canvas.drawCircle(x, y, size, paint);

size declares the radius in pixel.

Is there a way to convert pixels into density pixels? Any method or simliar?

Thanks in advance

网友答案:

I think the formula you are looking for (dip -> px) is published here:

What is the correct way to specify dimensions in DIP from Java code?

相关阅读:
Top