如何从一点到另一点延迟重绘点(android)?它下面的这些代码延迟了保持绘图,我想要的是从一点延迟到另一点。
public void reDraw2() {
drawPaint.setColor(0xFF660000);
// TODO Auto-generated method stub
//alphabetDrawingCanvasGlobal.recordPoints;
int cnt = 0;
for(final PointF point: recordPoints) {
// System.out.println("touchX>>" + point.x + "TouchY>>" + point.y);
if (cnt == 0) {
// do something here like draw text;
drawPath.moveTo(point.x, point.y);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cnt++;
} else {
// do something here like draw text;
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
drawPath.lineTo(point.x, point.y);
}
invalidate();
}
答案 0 :(得分:1)
这是一种可怕的做法。更好的方法是设置计时器。当计时器熄灭时,更新您想要绘制的所有内容的位置,然后使视图无效。然后让onDraw函数再次绘制它,它将获取新的位置信息。