Android : Android Canvas.ClipPath

on Saturday, March 28, 2015


I wanna clip a circle region, but somehow I got a rectangle, not a circle. And here is my code:



protected boolean drawChild(Canvas canvas, View child, long drawTime) {
mRevealPath.reset();
mRevealPath.addCircle(mCenterX, mCenterY, mRevealRadius, Path.Direction.CW);
final int state = canvas.save();
canvas.clipPath(mRevealPath);
boolean isInvalidate = super.drawChild(canvas, child, drawTime);
canvas.restoreToCount(state);
return isInvalidate;
}


I add a LinearLayout with a TextView in it as a child to test.


0 comments:

Post a Comment