How to fill rectangle with opacity in android

android, android-canvas

Solution

You can use the `Alpha` property of Paint class.

`myPaint.setAlpha(10);` will help you.

Problem

I can fill rectangle with canvas draw rect: ``` Rect rt = new Rect(0, 0, getWidth(), getHeight()); myPaint.setColor(myColor); myPaint.setStyle(Style.FILL); canvas.drawRect(rt, myPaint); ``` But I need the method to fill rectangle with the opacity (in percent, with 0% is TRANSPARENT). How can I do that?

Original source