我想在空白画布上画圆圈,但不知道怎么做。 这是我用来在我的自定义ImageView类中创建Empty canvas的代码。
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);
答案 0 :(得分:3)
试试这个,在你的MainActivity中首先找到你的imageView然后:
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);
答案 1 :(得分:1)
试试这个:
如果您只想要一个没有填充的轮廓,则需要将“绘画”样式设置为笔划:
Paint p = new Paint();
p.setStyle(Paint.Style.STROKE);
如果你想要填充圆圈,那么:
Paint p = new Paint();
p.setStyle(Paint.Style.FILL);
或者您可以参考: http://android-coding.blogspot.in/2012/04/draw-circle-on-canvas-canvasdrawcirclet.html