I have a problem: I would like to draw a grey overlay on an image. There is a path and I would like to colour outside of the path. Clipping is not good, because the edges are not anti-aliased (and I have to make it work on 2.1).
I have made it work on camera (right side). There is a FrameLayout, holding a SurfaceView (camera preview) and a View over it. The view fills the overlay color on full canvas, then with xfermode deletes the paths (Mode.CLEAR).
Using the same method I get the picture on the right.
First I made my View an ImageView descendant, but that was completely bad. Then, I added an ImageView with the image below my view (like the camera preview), but the same result. Then Used other imageview out of the framelayout, but same. Of course, I always tried to set the bgcolor to transparent, draw Color.TRANSPARENT, but it didn’t work. I don’t know what is the problem. Maybe Mode.CLEAR clears the whole screen on that area? Why it is working with camera surfaceview and not with and imageview (or even another surfaceview)?
I have been googling for 7 hours, and no real solutions. Can you please help me what I am doing bad, and share some “tricks”? As I said before, I need anti-aliased edges (severals shapes have many curves and diagonals), so I cannot clip (not even if drawing strokes, its awful).
Thank you in advance.
I have found a solution. I build a path containing the full canvas too, then filling it EVEN_ODD. So start at leftmost point -> left side ->topleft -> topright -> bottomright->bottomleft->leftside->leftmost point->other poly points. And works 🙂