Im using a custom layout and at times I enable and disable the drawing cache.
The only gotcha is that I'm developing for min APIVersion 9, but anything below 14 produces the following error:
java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@41ee8a88
E/AndroidRuntime( 6954): at android.graphics.Canvas.throwIfRecycled(Canvas.java:1026)
E/AndroidRuntime( 6954): at android.graphics.Canvas.drawBitmap(Canvas.java:1065)
E/AndroidRuntime( 6954): at android.view.View.draw(View.java:13620)
E/AndroidRuntime( 6954): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/AndroidRuntime( 6954): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/AndroidRuntime( 6954): at android.view.View.draw(View.java:13589)
E/AndroidRuntime( 6954): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/AndroidRuntime( 6954): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/AndroidRuntime( 6954): at android.view.View.draw(View.java:13710)
E/AndroidRuntime( 6954): at android.widget.FrameLayout.draw(FrameLayout.java:467)
E/AndroidRuntime( 6954): at android.view.View.draw(View.java:13591)
E/AndroidRuntime( 6954): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/AndroidRuntime( 6954): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/AndroidRuntime( 6954): at android.view.View.draw(View.java:13589)
E/AndroidRuntime( 6954): at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/AndroidRuntime( 6954): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/AndroidRuntime( 6954): at android.view.View.draw(View.java:13710)
E/AndroidRuntime( 6954): at android.widget.FrameLayout.draw(FrameLayout.java:467)
E/AndroidRuntime( 6954): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2211)
E/AndroidRuntime( 6954): at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2281)
E/AndroidRuntime( 6954): at android.view.ViewRootImpl.draw(ViewRootImpl.java:2177)
E/AndroidRuntime( 6954): at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2045)
E/AndroidRuntime( 6954): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1854)
E/AndroidRuntime( 6954): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
E/AndroidRuntime( 6954): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
E/AndroidRuntime( 6954): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
E/AndroidRuntime( 6954): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
E/AndroidRuntime( 6954): at android.view.Choreographer.doFrame(Choreographer.java:532)
E/AndroidRuntime( 6954): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
E/AndroidRuntime( 6954): at android.os.Handler.handleCallback(Handler.java:725)
E/AndroidRuntime( 6954): at android.os.Handler.dispatchMessage(Handler.java:92)
I'm not directly using any bitmaps, I'm really not sure what the problem is. If I take out the line setting setDrawingCacheEnabled(false)
, things work, but I'd like to keep it in for performance.