1

I have the following code which splits an image in half and animate each part in different direction:

final AnimatorSet mSetAnim = new AnimatorSet();
final Animator topAnim = ObjectAnimator.ofFloat(topImage, "translationY", (bmp.getHeight() / 2) * -1);
final Animator bottomAnim = ObjectAnimator.ofFloat(bottomImage, "translationY", bmp.getHeight() / 2);
mSetAnim.setDuration(duration); 
mSetAnim.playTogether(topAnim, bottomAnim);
mSetAnim.start();

I'm using NineOldAndroids in order to support old android versions but for some reason no matter what value i put in 'duration' it doesnt seem to have any affect. The animation duration stays the same - half a second more or less.

When i use android's animation apis i can see that the duration is changing.

Any idea how to workarround this ?

AsafK
  • 2,425
  • 3
  • 32
  • 38
  • Using `mSetAnim.getDuration()`, Try printing in a toast to see what value exists at runtime and comment. – Mohammed Ali Dec 13 '14 at 07:12
  • 1
    Use `mSetAnim.setDuration(duration);` after playTogether() as is done in http://nineoldandroids.com/ – Mohammed Ali Dec 13 '14 at 07:35
  • @MohammedAli Ya habibi, it worked ! also just fyi mSetAnim.getDuration() was returning -1. Add an answer and i will accept it. – AsafK Dec 13 '14 at 09:34

1 Answers1

1

Using mSetAnim.getDuration(), Try printing in a toast to see what value exists at runtime.
Use mSetAnim.setDuration(duration); after playTogether() as is done in nineoldandroids.com.

Mohammed Ali
  • 2,758
  • 5
  • 23
  • 41