Draw From Old Canvas - Android

前端 未结 2 2060
闹比i
闹比i 2021-02-11 09:22

I\'m making an App that needs to be able to draw new graphics on top of the last set.

This is my current onDraw() method -

protected void onDraw(Canvas          


        
2条回答
  •  悲&欢浪女
    2021-02-11 10:05

    You will have to store the previous image persistently onto a ArrayList, and during ondraw, loop through the ArrayList to redraw all items.

    something like this:

    for (Graphic graphic : _graphics) {
        bitmap = graphic.getBitmap();
        coords = graphic.getCoordinates();
        canvas.drawBitmap(bitmap, coords.getX(), coords.getY(), null);
    }
    

提交回复
热议问题