I\'m getting a IllegalStateException: underflow in restore exception, which is causing my application to crash. This started happening after android 4.3 update.
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.
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.