Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Howto use clipRect in API15

Tags:

android

canvas

i have a problem with a custom view with running on api 15 (Android 4.0.3)

the code:

canvas.clipRect(10,10,100,100, Region.Op.DIFFERENCE);
canvas.drawPaint(myPaint);

fills the full area of the view and not just the DIFFERENCE... it works with api 8 and 9...

Thanks for your help

like image 914
silly Avatar asked Feb 08 '12 10:02

silly


1 Answers

XOR, Difference and ReverseDifference clip modes are ignored by ICS if hardware acceleration is enabled.

Just disable 2D hardware acceleration in your view:

myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
like image 195
limmatplatz Avatar answered Oct 29 '22 03:10

limmatplatz