Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,17 @@ private void drawBackground(Canvas canvas) {
}
mPath.addOval(mDrawRect, Path.Direction.CW);
canvas.save();
canvas.clipPath(mPath, Region.Op.XOR);
// Ops other then Region.Op.INTERSECT and Region.Op.DIFFERENCE are deprecated since API 26
// as they have the ability to expand the clip. A new method Canvas.clipOutPath(Path) has been introduce
// to solve this issue. Since Android P using any ops other than Region.Op.INTERSECT and Region.Op.DIFFERENCE
// in Canvas.clipPath(Path, Region.Op) leads to IllegalArgumentException.
// More info can be found here:
// https://developer.android.com/reference/android/graphics/Canvas#clipPath(android.graphics.Path,%20android.graphics.Region.Op)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
canvas.clipOutPath(mPath);
} else {
canvas.clipPath(mPath, Region.Op.XOR);
}
canvas.drawRect(left, top, right, bottom, mBackgroundPaint);
canvas.restore();
}
Expand Down