简体   繁体   English

与Canvas.clipPath的Android 4.0兼容性问题

[英]Android 4.0 compatibility issues with Canvas.clipPath

Recently my application received quite a lot comments that "it's not working" on Android Ice Cream Sandwich with CM9. 最近我的应用程序收到了很多关于“它在冰淇淋三明治上用CM9不起作用”的评论。 I'm not able to reproduce the error on the emulator running Android 4.0 and thanks to the way android market works there's no way I can't contact those people to ask about the details. 我无法在运行Android 4.0的模拟器上重现错误,并且由于Android市场的工作方式,我无法联系这些人询问细节。

Luckily, one crash error report caught my eye. 幸运的是,一个崩溃错误报告引起了我的注意。 I'm using Canvas.clipPath to draw rounded corners... and looks like some phones are throwing UnsupportedOperationException when trying to use that function. 我正在使用Canvas.clipPath绘制圆角......看起来有些手机在尝试使用该功能时会抛出UnsupportedOperationException Quick look at Google reveals that it seems to be a problem when using hardware acceleration in Android 4.0 - so that's the potential reason of received comments. 快速浏览一下Google就会发现在Android 4.0中使用硬件加速似乎是一个问题 - 所以这是收到评论的潜在原因。

The question is - what's going on? 问题是 - 发生了什么? Weren't applications hardware accelerated in previous android versions? 以前的Android版本中的应用程序硬件加速了吗? Why such common function isn't supported? 为什么不支持这种常用功能? What's the workaround? 解决方法是什么?

Example usage of Canvas.clipPath can be found in my other post. Canvas.clipPath的示例用法可以在我的其他帖子中找到。 Check the accepted answer here: Android rounded corners in ListView 检查接受的答案: ListView中的Android圆角

Thanks in advance 提前致谢

In ICS, hardware acceleration was turned on by default. 在ICS中,默认情况下打开硬件加速。 Until 4.0, the default was that hardware acceleration was off. 到4.0之前,默认是硬件加速已关闭。 Hardware acceleration does not support clipPath (and a few other operations, see more here http://android-developers.blogspot.com/2011/03/android-30-hardware-acceleration.html ) I am facing the same issue. 硬件加速不支持clipPath(以及其他一些操作,请参阅http://android-developers.blogspot.com/2011/03/android-30-hardware-acceleration.html )我面临同样的问题。 As a quick fix I will turn off acceleration for the entire application, and later I will rewrite the code not to use clipPath 作为一个快速修复,我将关闭整个应用程序的加速,后来我将重写代码不使用clipPath

You can turn off hardware acceleration only on the specific view that is causing problems. 您只能在导致问题的特定视图上关闭硬件加速。 Check out my answer here: https://stackoverflow.com/a/14054331/596708 在这里查看我的答案: https//stackoverflow.com/a/14054331/596708

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM