In my application, I need to draw circles using a bitmap and the drawCircle () method.
Everything worked perfectly and exactly the same as before Android 6.0.
It still draws circles in all previous versions, but draws rectangles when I use the application in 6.0 format. But , if I change it to fill, it draws a circle in both api 22 and api 23. Does anyone have the same problem or some idea why this happens?
Here is the source code and a screenshot (the application runs on API 23 on the left and API 22 on the right). same application for different api
public final class Circle1View extends View { private float xCenter, yCenter; private Bitmap grid = null; public Circle1View (Context context) { super(context); init(); } private void init() { setLayerType(View.LAYER_TYPE_SOFTWARE, null); } @Override protected void onDraw(Canvas canvas) { int w = getWidth(); int h = getHeight(); xCenter = w / 2; yCenter = h / 2; drawBitmaps(w, h); canvas.translate(xCenter, yCenter); canvas.scale(xCenter, yCenter); canvas.drawBitmap(grid, null, new RectF(-1, -1, 1, 1), null); } private void drawBitmaps(int w, int h) { grid = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(); canvas.translate(xCenter, yCenter); canvas.scale(xCenter, yCenter); Paint gridPaint = new Paint(); gridPaint.setStrokeWidth(0.01f);
android android-6.0-marshmallow
Darja Tretjakova
source share