qq_29232445
qq_29232445
采纳率0%
2016-08-29 09:20 阅读 1.0k

recycled bitmap android

android代码中的问题,注不是imagview的回收问题是textview的回收问题

java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@2e09f030
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1282)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.graphics.Canvas.drawBitmap(Canvas.java:1416)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:539)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.widget.TextView.onDraw(TextView.java:5414)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.View.draw(View.java:15305)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.View.draw(View.java:15214)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewGroup.drawChild(ViewGroup.java:3414)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3205)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.View.draw(View.java:15308)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.View.draw(View.java:15214)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewGroup.drawChild(ViewGroup.java:3414)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3205)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.View.draw(View.java:15212)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewGroup.drawChild(ViewGroup.java:3414)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3205)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.View.draw(View.java:15212)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewGroup.drawChild(ViewGroup.java:3414)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3205)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.View.draw(View.java:15212)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewGroup.drawChild(ViewGroup.java:3414)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3205)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.View.draw(View.java:15308)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.widget.FrameLayout.draw(FrameLayout.java:598)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2674)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2779)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewRootImpl.draw(ViewRootImpl.java:2685)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2425)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2048)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1105)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6204)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:799)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:612)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.Choreographer.doFrame(Choreographer.java:581)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.view.Choreographer$FrameHandler.handleMessage(Choreographer.java:714)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.os.Looper.loop(Looper.java:135)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5669)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at java.lang.reflect.Method.invoke(Native Method)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at java.lang.reflect.Method.invoke(Method.java:372)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
08-29 15:43:52.889 26558-26558/com.BDB.bdbconsumer W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • FFZ2009 FFZ2009 2016-08-29 09:48

    你的TextView是不是设置了drawableTop,drawableBottom,,drawableXXX之类的属性,或者在代码中使用了setCompoundDrawables()?
    如果这些属性 指向的资源图片不存在,或运行的时候找不到的话,尤其是指向的是android系统中的资源图片,会抛出trying to use a recycled bitmap 这样的异常。
    比方说drawableTop指向了@android:drawable/sym_call_missed(android:drawableTop="@android:drawable/sym_call_missed"),
    这个资源sym_call_missed不是每个Android版本都有的,如果在测试设备的Android版本没有 这个图片,就会引发 “trying to use a recycled bitmap android.graphics.Bitmap@2e09f030 throwIfCannotDraw "的异常。

    如果使用了setCompoundDrawables(..),也有可能setCompoundDrawables(..)中的drawable参数在运行时是null,可以检查一下代码。

    点赞 评论 复制链接分享
  • FFZ2009 FFZ2009 2016-08-30 01:24

    说错了一点,请忽略最后一句。setCompoundDrawables(..)中的drawable参数在运行时是null不会引起你遇到的异常。

    点赞 评论 复制链接分享