彻底解决 Canvas 引起的 java.lang.unsupported operation exception, android.view.GLES20Canvas.clipPath(GLES20
来源:互联网 发布:sra数据上传 编辑:程序博客网 时间:2024/06/09 16:06
最近在做一个电子书项目,想要把开源的Shelves+iReader的翻页卷曲等弄到一起,在做卷曲效果时遇到以下问题:
java.lang.unsupported operation exception, android.view.GLES20Canvas.clipPath(GLES20Canvas...
万能的谷哥告诉我,这是硬件加速的问题,可是我从来没开启过硬件加速啊,做了个测试,View层的硬件加速已经干掉了
,那硬件加速肯定来自于Canvas绘制层了,测试了下,果然是绘制层开启了硬件加速。
给一个链接,讲硬件加速讲的很清楚的文章:点击查看
综合看了之后解决了,即在AndroidManifest.xml application下设定:
<application android:label="@string/application_name" android:hardwareAccelerated="false">
---------------------------------------------------------------------------------------------------------------------------------------------
关于 Hardware Acceleration
1、不同层级的加速:
Application
<applicationandroid:hardwareAccelerated="true" ...>
Activity
<application android:hardwareAccelerated="true"> <activity ... /> <activity android:hardwareAccelerated="false" /></application>
Window
getWindow().setFlags( WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
View
myView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
2、如何判断是否开启了硬件加速
在绘制之前,你必须做该测试 Canvas.isHardwareAccelerated()
替代View.isHardwareAccelerated()
在必要时。
View.isHardwareAccelerated() ;//returns true if the View is attached to a hardware accelerated window.Canvas.isHardwareAccelerated();// returns true if the Canvas is hardware accelerated
3、开启硬件加速之后,许多2D的绘制方法会抛出异常:
- Canvas
clipPath()
clipRegion()
drawPicture()
drawTextOnPath()
drawVertices()
- Paint
setLinearText()
setMaskFilter()
setRasterizer()
- Xfermodes
AvoidXfermode
PixelXorXfermode
In addition, some operations behave differently with hardware acceleration enabled:
- Canvas
clipRect()
:XOR
,Difference
andReverseDifference
clip modes are ignored. 3D transforms do not apply to the clip rectangledrawBitmapMesh()
: colors array is ignored
- Paint
setDither()
: ignoredsetFilterBitmap()
: filtering is always onsetShadowLayer()
: works with text only
- PorterDuffXfermode
PorterDuff.Mode.DARKEN
will be equivalent toSRC_OVER
when blending against the framebuffer.PorterDuff.Mode.LIGHTEN
will be equivalent toSRC_OVER
when blending against the framebuffer.PorterDuff.Mode.OVERLAY
will be equivalent toSRC_OVER
when blending against the framebuffer.
- ComposeShader
ComposeShader
can only contain shaders of different types (aBitmapShader
and aLinearGradient
for instance, but not two instances ofBitmapShader
)ComposeShader
cannot contain aComposeShader
转自:http://www.cnblogs.com/lonelyDog/archive/2012/07/12/2588477.html
- 彻底解决 Canvas 引起的 java.lang.unsupported operation exception, android.view.GLES20Canvas.clipPath(GLES20
- 彻底解决 Canvas 引起的 java.lang.unsupported operation exception, android.view.GLES20Canvas.clipPath(GLES20
- 彻底解决 Canvas 引起的 java.lang.unsupported operation exception
- java.lang.UnsupportedOperationException android.view.GLES20Canvas.clipPath(GLES20Canvas.java:451
- Android 异常 java.lang.UnsupportedOperationException at android.view.GLES20Canvas.clipPath(GLES20Canv
- java.lang.NullPointerException at android.view.GLES20Canvas.setupModifiers
- 滑动解锁 android Canvas自定义控件中硬件加速引起的canvas.clipPath问题
- Android canvas.clipPath无效
- Android canvas clipPath 问题
- Android 4.1.1 bug? Canvas的clipPath实现圆形图片
- Andrdoid自定义View之canvas.clipPath(path);
- GLES20Canvas.java:424 java.lang.UnsupportedOperationException
- 关于dialog引起的java.lang.IllegalArgumentException:View=com.android.internal.policy.impl.PhoneWindow$Deco
- 关于dialog引起的java.lang.IllegalArgumentException:View=com.android.internal.policy.impl.Ph
- canvas.clipPath canvas.clipRect() 无效的原因
- Maven项目中缺少jar包引起的报错 nested exception is java.lang.NoClassDefFoundError
- Exception starting filter struts2 引起java.lang.NullPointerException
- Android -- Canvas java.lang.UnsupportedOperationException
- js中运算符的优先级
- android 控件 下拉刷新 FlyRefersh
- 写给曾经浮躁过和现在正浮躁的程序员
- 2011年山东ACM第二届省赛 Mathman Bank(模拟)
- Andorid程序安装,替换及卸载操作
- 彻底解决 Canvas 引起的 java.lang.unsupported operation exception, android.view.GLES20Canvas.clipPath(GLES20
- jQurey全选,反选,不全选功能实现
- SurfaceView介绍
- jquery autocomplete 插件的使用
- Android studio插件GsonFormat 的使用
- iOS学习笔记75-NSURLSession使用实战教程
- 【jQuery】 ajax 提交表单问题--双击会重复提交;success函数不执行
- 9.1 数据库事务概述
- (OK) CORE - 不能正常初始化 - Fedora23 - /var/log/core-daemon.log - /root/.core/configs/m-MPE-manet.imn