0

i'm attempting to draw pixel density independent shapes to the screen. I assume i need canvas.getDensity(), as there is no action like

canvas.drawCircle(cx,cy,60di,paint). //di: density independent pixel

canvas.getDensity() is returning 0, however. I saw on a different post a suggestion of disabling the GPU to fix this. I don't want to disable the GPU on my user's phones' though, even if I knew how. how do I get around this?

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
Androidcoder
  • 4,389
  • 5
  • 35
  • 50
  • possible duplicate of [getting the screen density programmatically in android?](http://stackoverflow.com/questions/3166501/getting-the-screen-density-programmatically-in-android) – Greg Hewgill Jul 01 '14 at 09:42

1 Answers1

0

I found the answer to this here: getting the screen density programmatically in android?

Use getResources().getDisplayMetrics().density or context.getResources().getDisplayMetrics().density to get:

0.75 - ldpi

1.0 - mdpi

1.5 - hdpi

2.0 - xhdpi

3.0 - xxhdpi

4.0 - xxxhdp

Community
  • 1
  • 1
Androidcoder
  • 4,389
  • 5
  • 35
  • 50