views:

484

answers:

2

Hi,

I am trying to create animation that moves an image.

Lets have a look at following (like image locations on screen):

  • 01 02
  • 03 04

If I move from 01 to 02, 03 to 04, 01 to 03, 02 to 04, TranslateAnimation works fine.

But when I do 01 to 04 I will have no visual animation, and image takes immediate vertical position.

Could you please suggest what could be wrong?

Thanks.

+1  A: 

Care to post your code? I am guessing one of your parameters is wrong and it for whatever reason it doesn't affect your other cases.

hacken
A: 

Are you setting the duration and interpolator? This code works for me (was struggling with the same issue tonight):

trans = new TranslateAnimation(0, 100, 0, 100);
trans.setDuration(250);
trans.setInterpolator(new AccelerateInterpolator(1.0f));
someView.startAnimation(trans);

Also, I found that most elements don't actually have a width or height when queried in an activities constructor, so trying to transform based on those is going to give you a lot of 0->0 movement (ie: none) If you are animating based on element dimensions you may want to do some logging/Toasting to make sure you actually have a width/height at the point that you create the animation.

Toji