Reputation: 571
So while my TranslateAnimation
goes through its 10 second animation, its position doesn't actually update at all.
The only time it DOES update is when the animation finishes.
So how can I get the TranslateAnimation
to update its position WHILE it is animating?
By update its position, I mean, if I check for its position, IE; the top bottom left and right coordinates of the view, I should get a different set of numbers if it has moved.
But in this case, I am getting the position of the view's ORIGINAL location, which is not what I want. I want the position of the View AS it is moving during its animation, but there seems to be no way to do that.
Upvotes: 1
Views: 327
Reputation: 4036
Did you try using an ObjectAnimator? The following code would actually move your view instead of just animating:
ObjectAnimator animation = ObjectAnimator.ofFloat(yourView, "translationX", 0.0f, yourHorizontalTranslationTarget);
ObjectAnimator animation = ObjectAnimator.ofFloat(yourView, "translationY", 0.0f, yourVerticalTranslationTarget);
Note that yourHorizontalTranslationTarget
and yourVerticalTranslationTarget
are absolute values in pixels, rather than a percentage.
You could then join them in an AnimationSet so they would be executed at the same time.
Upvotes: 1