場景
在使用Paint時候下面兩個方法都調用了
Paint.setAlpha()
Paint.setColor()
問題
setAlpha()方法不生效
原因
setColor()是包含透明度設置的,因為setAlpha()執(zhí)行在后,所以被setColor重置了,沒有看到效果
setColor()
Set the paint's color. Note that the color is an int containing alpha as well as r,g,b. This 32bit value is not premultiplied, meaning that its alpha can be any value, regardless of the values of r,g,b. See the Color class for more details.
setAlpha()
Helper to setColor(), that only assigns the color's alpha value, leaving its r,g,b values unchanged. Results are undefined if the alpha value is outside of the range [0..255]
解決
把setAlpha()放在setColor()方法之后