我想知道指针被复制的原因
所有指针都将转动,每次指针将被复制
如果你能详细告诉我这个原则会有很多帮助
private Canvas canvas;
private SurfaceView surfaceView;
private SurfaceHolder holder;
private void initSurface() {
surfaceView = (SurfaceView) findViewById(R.id.surface);
holder = surfaceView.getHolder();
new Thread(new Runnable() {
@Override
public void run() {
int time = 0;
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.mipmap.line2);
while (true) {
synchronized (holder) {
canvas = holder.lockCanvas();
if (canvas != null) {
canvas.save();
canvas.rotate(360 / 60 * time,
Utils.getScreenWidthPx(MainActivity.this) / 2,
Utils.getScreenHeightPx(MainActivity.this) / 2
);
canvas.drawBitmap(bitmap
, Utils.getScreenWidthPx(MainActivity.this) / 2
, Utils.getScreenHeightPx(MainActivity.this) / 2
, null);
canvas.restore();
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
time++;
if (time == 60) {
time = 0;
}
}
if (canvas != null) {
holder.unlockCanvasAndPost(canvas);
}
}
}
}).start();
}