Search code examples
androidandroid-custom-viewgauge

canvas.drawText seems does not work properly in Android api >19


I have an issue that is making me crazy. I created an Android library for a Custom gauge view of a car applicaction. On this gauge view there's a scale with values drawn with function Canvas.drawText(). Everything was working fine when running whis view on devices with API 19 and 22, up to when last week I updated Android Studio 2.2. Since that time the values on the scale are not properly written if I run it on a device with API >19. If I run it on device with API =< 19 everything is fine. This is the test project that can be cloned from Github:

https://github.com/dequadelisonz/CarDashDemo.git

This is what I should correctly see (on device with API <=19): enter image description here

And this is what I see on device with API >19: enter image description here

As you can see in the 2 gauges there are only few digits in one of the two. All the other texts seems to be disappeared. Hope someone can do the trick to fix this thing.... Thanks!


Solution

  • Fixed thanks to this post https://stackoverflow.com/a/14989037/746068

    It seems there is a bug on Android APIs > 15 so that text is not properly drawn on canvas.