Prevent drawing lines on black portion of an imageview

23 Views Asked by At

enter image description here

While drawing a line or circle using paint i can able to draw on the black portion of the imageview.The image is a custom imageview with zoom that extending to AppCompactImageView.And for drawing ,we use a Custom view that extends View and lines are drawing using paint in a canvas

1

There are 1 best solutions below

0
Pawan Harariya On

You need to define a clipping region, and then you will only be able to draw inside that clipping region.

canvas?.clipRect(100,200,600,800)

where 100,200,600 and 800 are coordinates for left, top, right and bottom of you clipping region.

Sample Output:

Sample Output