I would like to draw bitmap(with specified color) on canvas.
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.RED);
// create bitmap
canvas.drawBitmap(bitmap, 0, 0, paint);
Well, the bitmap is visible on the canvas, but color of drawable didn’t change.
Where is the problem?
A bitmap contains an image and drawing an image in single color doesn’t make any sense. What do you expect it to do? Draw a red rectangle? Shapes can be drawn with color, not images…
The
Colorattribute of yourPaintwill be ignored. ThatPaintparameter is used to pass other settings such as anti-aliasing.I hope this clarifies.