Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Canvas Clear with transparency

I am trying to "erase" from a canvas. Just as a VERY simple test of clearing a canvas, I have implemented the following:

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.drawColor(Color.argb(140, 0, 0, 0));
    canvas.drawColor(0, Mode.CLEAR);
}

Color.argb(140, 0, 0, 0) sets the view this view is drawn over to be dimmed. drawColor(0, Mode.CLEAR) makes the screen completely black, rather than removing the dimming applied earlier. The idea was taken from here

like image 861
rperryng Avatar asked Feb 18 '14 20:02

rperryng


1 Answers

Use the following.

 canvas.drawColor(Color.TRANSPARENT,Mode.CLEAR);
like image 155
Y0Gi Avatar answered Sep 18 '22 12:09

Y0Gi