问题
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