私は座標の配列を作成しました。画像の中心は、それらの座標を移動する必要があります。私はそれを達成するためにTranslateAnimationを使用しました。しかし、アニメーションの間、画像は最後の2つの座標内を移動しています。以下 は私のコードです:異なるx、y座標を使用した画像の移動
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);
}
}
上記の機能は、ボタンのクリックで呼び出されました。