underflow in restore in android 4.3

后端 未结 2 1847
暗喜
暗喜 2021-02-14 21:20

I\'m getting a IllegalStateException: underflow in restore exception, which is causing my application to crash. This started happening after android 4.3 update.

相关标签:
2条回答
  • 2021-02-14 21:49

    The bug is in this section of your code:

        if(bitMapWidth+mX<mCanvasWidth){
            canvas.translate(bitMapWidth+mX, 0);    
            if(!mBitMapBuffer.isRecycled()){
                canvas.drawBitmap(mBitMapBuffer, 0, 0, null);
            }
            canvas.restore();                   
        }
    

    You are calling restore() without calling save() first. You don't even need that call to translate() either, you could just pass the x and y coordinates to the drawBitmap() call.

    0 讨论(0)
  • 2021-02-14 21:52

    public void restore ()

    Added in API level 1 This call balances a previous call to save(), and is used to remove all modifications to the matrix/clip state since the last save call. It is an error to call restore() more times than save() was called.

    0 讨论(0)
提交回复
热议问题