-1

For example: The view will animate, it will wait for 4 seconds as it is, again it will animate and it will wait for 2 seconds and then again 4 and 2 secs continously. I tried using scheduleAtFixedRate method from Timer class. Its working for any one time interval, how do I make it work for 4 and 2 seconds continously. Thanks

Javed Khatri
  • 719
  • 2
  • 7
  • 9

1 Answers1

0

Alternating the start offset can be achieved by using an animation listener, changing its offset on animation end, and restarting the animation.

    Animation a = //initialize here
    a.setStartOffset(2000);
    a.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            a.setStartOffset(a.getStartOffset() == 2000 ? 4000 : 2000);
            a.start();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    a.start();
Dmitri Timofti
  • 2,428
  • 1
  • 22
  • 25