Ben Luk
Ben Luk

Reputation: 755

Android: How to avoid restart after Animation finish?

the image will go back to 0,0 after animation finish how to set not go back? still stay in 100,100

Animation am = new TranslateAnimation((float)0(), (float)100, (float)0,(float)100);

am.setDuration(5000);
am.setRepeatCount(0);
point.startAnimation(am);

Upvotes: 2

Views: 602

Answers (1)

Ken Wolf
Ken Wolf

Reputation: 23269

Use Animation.setFillAfter(true) to persist the final animation state.

http://developer.android.com/reference/android/view/animation/Animation.html#setFillAfter(boolean)

If fillAfter is true, the transformation that this animation performed will persist when it is finished. Defaults to false if not set. Note that this applies to individual animations and when using an AnimationSet to chain animations.

Animation am = new TranslateAnimation((float)0(), (float)100, (float)0,(float)100);

am.setDuration(5000);
am.setFillAfter(true);
am.setRepeatCount(0);
point.startAnimation(am);

Upvotes: 4

Related Questions