座標の配列を作成しました。画像の中心は、これらの座標を移動する必要があります。私はそれを達成するためにTranslateAnimationを使用しました。ただし、アニメーション中、画像は最後の2つの座標内で移動しています。以下は私のコードです:
private void CreateAnimationAndRun() {
// move to the different coordinates one by one
for(int k=0; k<xpoints.length; k++) {
if(k==0) {
x1 = xstart;
y1 = ystart;
} else {
x1 = xpoints[k-1];
y1 = ypoints[k-1];
}
x2 = xpoints[k];
y2 = ypoints[k];
TranslateAnimation translateAnimation = new TranslateAnimation(x1, x2, y1, y2);
translateAnimation.setDuration(1000);
translateAnimation.setAnimationListener(anim_listener);
imv1.startAnimation(translateAnimation);
}
}
上記の関数は、ボタンのクリックで呼び出されました。