Can I draw outside the bounds of an Android Canvas

前端 未结 5 1156
我在风中等你
我在风中等你 2020-11-29 06:27

I\'m porting an app written in a graphics environment that allows drawing to happen outside the bounds of the clipping rectangle. Any way to do this in Android?

5条回答
  •  眼角桃花
    2020-11-29 07:15

    To draw outside the bounds, you need to expand the clipRect of the canvas.

    Check out the overloaded clipRect methods on the Canvas class.

    Note - You will need to specify the Region operation because the default operation is INTERSECT. So something like this:

    Rect newRect = canvas.getClipBounds();
    newRect.inset(-5, -5)  //make the rect larger
    
    canvas.clipRect (newRect, Region.Op.REPLACE);
    //happily draw outside the bound now
    

提交回复
热议问题