Java – Android canvas does not draw path. When the point of path is not present

I encountered some problems with Android canvas when drawing the path

canvas.drawPath(polyPath,borderPaint);

I also have to draw other types like circles and polygons using canvas Every time we zoom in or out, we recalculate the path points to match the zoom level When using old APIs like Android 2.3 3. No problem But for newer APIs, such as Android 4 x. When we zoom in, some points can see the view (e.g. - 300300) After zooming in for a while, the visible area shows only a small part of my path Then suddenly the whole path disappeared If we shrink, it will appear again It stops rendering the same things as the canvas (other objects still display like icons) circles, ellipses or polygons

So I don't know how to draw the canvas, what changes? Is there anything I want to draw using canvas?

Solution

Add this row to the initialization of the view

setLayerType(View.LAYER_TYPE_SOFTWARE,null);

You can also refer to this guide for hardware level supported APIs

google API

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>