Android:如何在 API15 中使用 clipRect [英] Android: Howto use clipRect in API15

查看:14
本文介绍了Android:如何在 API15 中使用 clipRect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的自定义视图在 api 15 (Android 4.0.3) 上运行时遇到问题

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

代码:

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

填充视图的整个区域,而不仅仅是差异...它适用于 api 8 和 9...

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

感谢您的帮助

推荐答案

如果启用硬件加速,ICS 将忽略 XOR、Difference 和 ReverseDifference 剪辑模式.

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

只需在您的视图中禁用 2D 硬件加速:

Just disable 2D hardware acceleration in your view:

myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

这篇关于Android:如何在 API15 中使用 clipRect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆