1

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

nkron
  • 19,086
  • 3
  • 39
  • 27
RiadSaadi
  • 391
  • 2
  • 7
  • 16

2 Answers2

1

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

RiadSaadi
  • 391
  • 2
  • 7
  • 16
Maciej Boguta
  • 1,354
  • 1
  • 12
  • 15
1

Set the transfer mode as follows, before calling drawRec():

paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC));

Reset the painter afterwards, for further drawing:

paint.setXfermode(null);
paint.setColor(0xFFFFFFFF);