问题
I am trying to draw a board which consists of 35 small blocks and each small block is similar but when I use a bitmap to draw multiple times i.e 35 times then it clears the previous drawn image. At the end there is only one image left. So can anybody help me finding a solution for this.
Here is the code which I tried
protected void onDraw(Canvas canvas) { Bitmap empty=BitmapFactory.decodeResource(getResources(), R.drawable.empty);
for(int i=0;i<5;i++){
for(int j=0;j<7;j++){
canvas.drawBitmap(empty, curX, curY, null);
curX +=blockWidth;
}
curY=curY+blockHeight;
curX=0;
}
}
(curX->it keep track of the x coordinate and curY->keep track of y coordinate initial value of both curX and curY are 0, blockWeidth and blockHeight are constants with value 70px and 65px respectively)
来源:https://stackoverflow.com/questions/9789316/draw-multiple-times-from-a-single-bitmap