pleerock
pleerock

Reputation: 18846

Android -> apply animation to the object

I want to apply animation effects (for example, such as translate) to object after animation is finished. Ive used fillAfter="true" property, it's worked but there is another problem. When animation finished with this property, its look like object gets new positions. But then I use second animation to this object and object's positions are restore and animation goes from old position... I hope you understand me... (I think the problem is that animations apply to the View matrix, not to the object matrix) SDK 2.2 (not 3((()

so, Can you say me what should I do?


And again my answer:

After the first animation I've stored animated positions (xTo and yTo) and then when I've used second animation I started from this xTo and yTo positions to the new xTo and yTo positions. That's all. Thanks

Upvotes: 0

Views: 623

Answers (2)

pleerock
pleerock

Reputation: 18846

my answer:

After the first animation I've stored animated positions (xTo and yTo) and then when I've used second animation I started from this xTo and yTo positions to the new xTo and yTo positions. That's all. Thanks

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1007265

android:fillAfter="true" is probably not what you want. That only affects the pixels, not the widget itself (e.g., where it responds to touch events).

Instead, you need to add an AnimationListener to your Animation, and in onAnimationEnd(), do something to more permanently implement the change. For example, if you are translating a widget off-screen, in onAnimationEnd() you could call setVisibility(View.GONE) to make it disappear.

Upvotes: 1

Related Questions