Reputation: 340
I wants to draw Circle on empty canvas, but not getting how to do. This is code I'm using to create Empty canvas inside my custom ImageView class.
bmpBase = Bitmap.createBitmap(image_width, image_height, Bitmap.Config.ARGB_8888);
canvas = new Canvas(bmpBase);
Paint paint = new Paint();
paint.setColor(Color.BLUE);
canvas.drawCircle(100, 100, 30, paint);
Upvotes: 1
Views: 1142
Reputation: 18977
try this, in your MainActivity first find your imageView and then:
drawingImageView = (ImageView)findViewById(R.id.DrawingImageView);
Paint paint = new Paint();
paint.setColor(Color.BLUE));
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(15);
bmpBase = Bitmap.createBitmap(image_width, image_height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawCircle(100, 100, 30, paint);
drawingImageView.setImageBitmap(bitmap);
Upvotes: 3
Reputation: 3359
Try this:
You need to set the Paint style to stroke if you just want an outline with no fill:
Paint p = new Paint();
p.setStyle(Paint.Style.STROKE);
and if you want filled circle then:
Paint p = new Paint();
p.setStyle(Paint.Style.FILL);
Or you can refer this: http://android-coding.blogspot.in/2012/04/draw-circle-on-canvas-canvasdrawcirclet.html
Upvotes: 2