Search code examples
androiddrawingoverlapping

how to resolve overlapping on draw of multiple path


i want to draw multiple path with multiple paint stroke width on the canvas, but overlapping problem occurs on collision of path.

color overlapping when drawing multiple path

Above link contains explanation. Overlapping occurs when i set alpha to paint. But this is requirement of application. If other way to make paint semi-transparent with using alpha. Please suggest. Thanks


Solution

  • I think it'll help you

    mPaint.setARGB(90, 255, 0, 0);
    mPaint.setXfermode(new AvoidXfermode(Color.RED, 90, Mode.AVOID));       
    

    if you are drawing on canvas than you need to set transparent bitmap to canvas otherwise AvoidXfermode will detect rgb of image.