How to fill rectangle with opacity in android

匿名 (未验证) 提交于 2019-12-03 08:36:05

问题:

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?

回答1:

You can use the Alpha property of Paint class.

myPaint.setAlpha(10); will help you.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!