2013-10-22 89 views
0

我試圖繪製像素密度獨立的形狀在屏幕上。我想我需要canvas.getDensity(),因爲有像canvas.getDensity返回0

canvas.drawCircle(CX,CY,60di,油漆)沒有動作。 //二:然而密度獨立像素

canvas.getDensity()被返回0,。我在另一篇文章中看到了禁用GPU來解決這個問題的建議。儘管我知道如何,但我不想在用戶手機上禁用GPU。我如何解決這個問題? 。

+0

的可能重複(http://stackoverflow.com/questions/3166501/getting-the-screen-density -programmatically功能於機器人) –

回答

0

我發現這個問題的答案在這裏: getting the screen density programmatically in android?

使用getResources()getDisplayMetrics()密度或context.getResources()getDisplayMetrics()密度 獲得:。

0.75 - LDPI

1.0 - MDPI

1.5 - HDPI

2.0 - xhdpi

3.0 - xxhdpi

4.0 - [?在Android的程序獲得的屏幕密度] xxxhdp