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

发布于 2024-12-26 00:29:05 字数 590 浏览 0 评论 0原文

最近,我的应用程序收到了很多评论,说“它在带有 CM9 的 Android Ice Cream Sandwich 上不起作用”。我无法在运行 Android 4.0 的模拟器上重现该错误,并且由于 Android 市场的工作方式,我无法联系那些人询问详细信息。

幸运的是,一份崩溃错误报告引起了我的注意。我正在使用 Canvas.clipPath 绘制圆角...并且看起来有些手机在尝试使用该功能时抛出 UnsupportedOperationException 。快速查看 Google 发现,在 Android 4.0 中使用硬件加速时似乎存在问题 - 这就是收到评论的潜在原因。

问题是——发生了什么事?以前的 Android 版本中应用程序没有硬件加速吗?为什么这么常用的功能不支持呢?解决方法是什么?

Canvas.clipPath 的示例用法可以在我的另一篇文章中找到。在此处检查已接受的答案:ListView 中的 Android 圆角

提前致谢

Recently my application received quite a lot comments that "it's not working" on Android Ice Cream Sandwich with 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.

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. 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.

The question is - what's going on? Weren't applications hardware accelerated in previous android versions? Why such common function isn't supported? What's the workaround?

Example usage of Canvas.clipPath can be found in my other post. Check the accepted answer here: Android rounded corners in ListView

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

笑脸一如从前 2025-01-02 00:29:05

在ICS中,硬件加速默认开启。在 4.0 之前,硬件加速默认是关闭的。
硬件加速不支持clipPath(以及一些其他操作,请在此处查看更多信息 http://android-developers.blogspot.com/2011/03/android-30-hardware-acceleration.html)
我面临着同样的问题。作为快速修复,我将关闭整个应用程序的加速,稍后我将重写代码以不使用clipPath

In ICS, hardware acceleration was turned on by default. Until 4.0, the default was that hardware acceleration was off.
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. As a quick fix I will turn off acceleration for the entire application, and later I will rewrite the code not to use clipPath

陌伤浅笑 2025-01-02 00:29:05

您只能在导致问题的特定视图上关闭硬件加速。在这里查看我的答案:https://stackoverflow.com/a/14054331/596708

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文