Can't compress a recycled bitmap

后端 未结 3 2251
迷失自我
迷失自我 2021-02-19 22:20

I\'m trying to save a Layout into an Image in the SDCard but I get this error. I tried several codes I found in this forum but all of them have the same compress call that is gi

3条回答
  •  感情败类
    2021-02-19 22:52

    This resolved my issues.

    View drawingView = get_your_view_for_render;
    drawingView.buildDrawingCache(true);
    Bitmap bitmap = drawingView.getDrawingCache(true).copy(Config.RGB_565, false);
    drawingView.destroyDrawingCache();
    // bitmap is now OK for you to use without recycling errors.
    

提交回复
热议问题