如何填写矩形与Android的透明度 [英] How to fill rectangle with opacity in android

查看:133
本文介绍了如何填写矩形与Android的透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以填补长方形帆布画矩形:

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

但我需要填写矩形的不透明度(百分比,0%是透明)的方法。
结果我该怎么做?

But I need the method to fill rectangle with the opacity (in percent, with 0% is TRANSPARENT).
How can I do that?

推荐答案

您可以使用油漆的阿尔法属性类<一href=\"http://developer.android.com/reference/android/graphics/Paint.html\">http://developer.android.com/reference/android/graphics/Paint.html

myPaint.setAlpha(10); 将帮助你。

这篇关于如何填写矩形与Android的透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆