Canvas's density

狂风中的少年 提交于 2019-12-24 16:22:37

问题


I'm having trouble with getting the Canvas's density in my onDraw function. If I run the code in the emulator, c.getDensity(), where "c" is my Canvas, I get 320, which is the density I expect. But when I run this code on my actual phone, the same function returns 0. As you can imagine, the visual result is then fundamentally different...

Defining the bitmap background either from the xml file or from the onDraw function doesn't make any difference.

Do you have any idea for the cause of this behaviour?

The version of Android used is 4 (4.1.2 for the emulator and 4.1.1 for the actual phone).

Thanks for the time you will spend trying to help me.


回答1:


On my actual phone, the density returned by getDensity was 0 because it was configured to force the use of the GPU. With this option disabled, the correct density of 320 is returned.



来源:https://stackoverflow.com/questions/13329538/canvass-density

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!