我想在android上将图像从0,0移动到100,100。我使用翻译动画这样做:在Android上使用翻译动画移动图像的问题
public void moveImage() {
// move image from 0,0 to 100,100
mAnimationTranslate = new TranslateAnimation(0, 100, 0, 100);
mAnimationTranslate.setDuration(1000);
mAnimationTranslate.setAnimationListener(this);
this.startAnimation(mAnimationTranslate);
}
public void onDraw (Canvas canvas) {
super.onDraw(canvas);
canvas.drawBitmap(bmp, x, y, null);
}
public void onAnimationEnd(Animation animation) {
// stop animation and draw the image at 100,100
x = 100;
y = 100;
}
问题是,当动画完成在100,100,图像将移动到200,200短的时间和回100,100到底。我的代码有问题吗?如何让图像正确停止在100,100?