private void rePaint(Rect rect, int i, int j) {
Canvas canvas = null;
try {
canvas = holder.lockCanvas(rect);
String imageName = cards[i - 1][j - 1].getName();
int id = getResources().getIdentifier(imageName, "drawable", getContext().getPackageName());
Bitmap image = BitmapFactory.decodeResource(getResources(), id);
// Log.d("OLOLO", Integer.toString(id));
// Log.d("OLOLO", imageName + j + i);
Log.d("OLOLO", rect.toString());
canvas.drawBitmap(image, null, rect, null);
} finally {
if (canvas != null) {
holder.unlockCanvasAndPost(canvas);
}
}
}
BUT。在第一次触摸时,图片全屏显示。和Log.d(“OLOLO”,rect.toString());返回Rect(0,0-800,404)。但是在rePaint返回Rect之前检查了这个rect(300,0 - 400,100)/它如何改变他的大小?
PS:第二次触摸和其他工作正常。 O_O PSS:我找到了答案。 LiveWallpaper with SurfaceHolder.lockCanvas(Rect dirty) 双缓冲引起了我的问题