Draw transparent text on canvas

android, android-canvas, draw, transparent

Solution

paint.setColor() includes alpha, so when you call paint.setColor(textColor) you are overwriting the alpha that you set in paint.setAlpha(1). Try setting the alpha and text color at the same time with:

paint.setColor(Color.argb(alpha, red, green, blue));

Problem

I am trying to write a semi-transparent text on a canvas. I see the string written on the canvas but the transparency doesn't seem to work. Here's my code: ``` public void onDraw(Canvas canvas, Paint paint) { paint.setAlpha(1); paint.setAntiAlias(true); paint.setTextSize(this.textSize); paint.setColor(textColor); canvas.drawText(text,x,y,paint); Logs.add("onDraw DefaultScoreGottenText currentAlpha = " + this.currentAlpha); showAnimation(null); } ``` The alpha property is set but doesn't seem to have any effects. I even try to create a new Paint object and send it to the drawText method. Didn't work either. Any ideas ?

Original source