Search code examples
androidcolorsimageviewtransparencyandroid-canvas

Fill a canvas with a transparent color in Android


Good Morning,

I have an ImageView that I initialized with #99aaaaaa color (it corresponds to 153,170, 170,170). after that I draw some lines with different colors. and Now I want to Fill my Canvas with the original color (#99aaaaaa).

The method myCanvas.drawColor(OriginalColor) fills the canvas with OriginalColor, but the lines still visible

    myPaint.setColor(OriginalColor);
    myPaint.setStyle(Paint.Style.FILL);
    myCanvas.drawRect(0, 0, 170, 170, myPaint); // my ImageView is  170X170

Also let lines visible.

Any help please, Thank You


Solution

  • as the canvas original color is semi transparent, then you draw something on it and draw another layer of semi transparent stuff, then its pretty obvious youll see the level-down-layer through the top transparent layer isnt it? another words, if you place a half transparent glass on your knees, ull still see the knees through it