how to fill canvas with a color [duplicate]

I want to fill a color inside a canvas , this is my code :

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); 

This code makes a circle with a border color. How can I fill the circle with a color?

2

2 Answers

Paint paint2 = new Paint(); paint2.setColor(Color.WHITE); paint2.setStyle(Style.FILL); canvas.drawPaint(paint2); 

You can make the following changes!!

you need to set corresponding paint style for that, for example Paint.Style.FILL or Paint.Style.FILL_AND_STROKE

You Might Also Like