Android 4.0 compatibility issues with Canvas.clipPath

Recently, there were a lot of comments in my application that “it does not work” on Android Ice Cream Sandwich with CM9. I can’t reproduce the error on an emulator running Android 4.0, and thanks to the way the Android market works, I can’t contact these people to find out more.

Fortunately, in my opinion there was one error message with an error. I use Canvas.clipPath to draw rounded corners ... and looks when some phones throw an UnsupportedOperationException when trying to use this function. A quick look at Google shows that this seems like a problem when using hardware acceleration in Android 4.0 - so this is a potential reason for the comments received.

The question is what's going on? Didn't apps accelerate in previous versions of Android? Why is this common feature not supported? What is the workaround?

An example of using Canvas.clipPath can be found in another post. Check the accepted answer here: Android rounded corners in ListView

Thank you in advance

+3
android exception compatibility canvas hardware-acceleration
Jan 07 2018-12-12T00:
source share
2 answers

In ICS, hardware acceleration was enabled by default. Prior to 4.0, it was set by default that hardware acceleration was disabled. Hardware acceleration does not support clipPath (and several other operations, see more details here http://android-developers.blogspot.com/2011/03/android-30-hardware-acceleration.html ) I encountered the same problem. As a quick fix, I will turn off acceleration for the entire application, and later I rewrote the code so as not to use clipPath

+6
Apr 10 2018-12-12T00:
source share

You can disable hardware acceleration only on a specific view that causes problems. See my answer here: stack overflow

+2
Dec 27 '12 at 12:14
source share



All Articles