Use hardwareAcceleration flag with Canvas.clipPath

寵の児 提交于 2019-12-23 20:32:57

问题


I'm porting a project made for the Galaxy Tab 1, for Galaxy Tab 2, but the apk runs slowly so I added the hardwareAccelerated flag on the AndroidManifest.XML of the new application.

But running give me the following error:

java.lang.UnsupportedOperationException
     at android.view.GLES20Canvas.clipPath(GLES20Canvas.java:287)
     at br.com.iba.view.PageCurlView.drawCurl(PageCurlView.java:284)
     at br.com.iba.view.PageCurlView.onDraw(PageCurlView.java:353)
     at android.view.View.draw(View.java:9291)

回答1:


I had the similar problem in my project with ImageView which doesn't support hardware acceleration. I circumvented this problem with this code:

mImageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

It work's for me.




回答2:


To prevent issues related to the version of the sdk, you should use:

if (android.os.Build.VERSION.SDK_INT >= 11) {
    mapView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
} 

I was getting java.lang.NoSuchMethodError: setLayerType.

This post is only for clarifying things.



来源:https://stackoverflow.com/questions/7401319/use-hardwareacceleration-flag-with-canvas-clippath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!