我想填充画布中的颜色,这是我的代码:
Bitmap bitMap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
bitMap = bitMap.copy(bitMap.getConfig(), true);
Canvas canvas = new Canvas(bitMap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(4.5f);
canvas.drawCircle(50, 50, 30, paint);
此代码创建一个带边框颜色的圆圈。如何用颜色填充圆圈?
答案 0 :(得分:8)
Paint paint2 = new Paint();
paint2.setColor(Color.WHITE);
paint2.setStyle(Style.FILL);
canvas.drawPaint(paint2);
您可以进行以下更改!!
答案 1 :(得分:5)
您需要为其设置相应的绘画样式,例如Paint.Style.FILL
或Paint.Style.FILL_AND_STROKE