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?
In general you just have to define a slightly transparent color when creating the shape. You can achieve that by setting the colors alpha channel. #FF000000 will get you a solid black whereas #00000000 will get you a 100% transparent black (well it isn't black anymore obviously).
Use imageView. setAlpha(100) .
You can use the Alpha
property of Paint class.
myPaint.setAlpha(10);
will help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With