开发者

Use hardwareAcceleration flag with Canvas.clipPath

I'm porting a project made for the Galaxy Tab 1, for Galaxy Tab 2, but the apk runs slowly so I added the hardwareA开发者_开发知识库ccelerated 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)


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜