2

I am programming a board game using the Android Platform. I am using Tween Animation, specifically the TranslateAnimation tool to create an animation that moves an ImageView object across the screen. I would like that ImageView to remain in its new position after the animation finishes. Please teach me how to do this?

This is a snippet of code that I am using to run the animation.

ImageView image = (ImageView) findViewById(R.id.ImageView)
Animation personal = new TranslateAnimation(0,100,0,100);
personal.setDuration(2000);
image.startAnimation(personal);

I am using Java to declare the animation instead of using an xml file because I don't know how to modify the fromXDelta, toXDelta, fromYDelta, toYDelta variables inside of the main class code.

Kai
  • 51
  • 2
  • 5

2 Answers2

2
animation.setfillEnabled(true);

animation.setFillAfter(true);
SirKnigget
  • 3,614
  • 2
  • 28
  • 61
0

I think you should set the image layout params. To keep the position in the end; the first answer I tried it, it was not useful.

Roman C
  • 49,761
  • 33
  • 66
  • 176
perry
  • 856
  • 1
  • 10
  • 22