3

I have a view that is animated using TranslateAnimation:

TranslateAnimation translateAnim = new TranslateAnimation(fromX, toX, fromY, toY);
translateAnim.setDuration(SLIDING_SPEED);
translateAnim.setInterpolator(new BounceInterpolator());
translateAnim.setFillAfter(true);
mSlidingView.startAnimation(translateAnim);

The animation works fine but after it's finished I can't click on the view anymore. Instead I can still click on its previous location.

I have searched for similar questions (here, here and here) on StackOverflow but none of them provides any solution. I have heard that the ObjectAnimator fixed this, but is there anything I can do using the previous API? (I don't want to rely on yet another third party library like NineOldAndroids to support the new animation API on pre-honeycomb devices). Oh and I have tried to invalidate the view but it doesn't change anything.

Any idea?

Thanks!

Community
  • 1
  • 1
Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158

2 Answers2

0

Well, I guess there is not link, but have you tried : (before setFillAfter)

translateAnim.setFillEnabled(true);
Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158
Mathieu de Brito
  • 2,536
  • 2
  • 26
  • 30
  • What viewGroup do you use ? ( I mean, in what kind of layout is your view translating ? ) – Mathieu de Brito May 09 '12 at 09:48
  • hum, look at this [link](http://stackoverflow.com/questions/4502580/view-still-there-but-not-visible-after-being-moved-out-by-animation) – Mathieu de Brito May 09 '12 at 09:56
  • As a workarround, you could set the new position of your view via setLayoutParams in the onAnimationEnd method of the animation listener. That's pretty dirty, but could fix the problem – Mathieu de Brito May 09 '12 at 09:58
  • Yes as a mentioned in my question, the guy is suggesting to use the new API but I don't want to (unless I **really** don't have the choice). Also the `SlidingDrawer` is not appropriate for what I want to achieve. – Amokrane Chentir May 09 '12 at 10:00
  • For your Workaround, could be a solution indeed. Let me try :) – Amokrane Chentir May 09 '12 at 10:01
0

In API 11+, We can do that by ObjectAnimator class.

In API 10-, When we translate a view, the visual view will be translated, but the physical location still in the old location, changing the margin of the translated view after finish the animation could solve the problem.

Mahmoud
  • 2,683
  • 1
  • 30
  • 32