Search code examples
androidandroid-animationtime-wait

Android - Leave A Time Between ImageButton Animations?


I have 6 ImageButton. I applied the same animation to all of them as below:

Animation anim1 = AnimationUtils.loadAnimation(this, R.anim.wave_scale);
img1.startAnimation(anim1);
img2.startAnimation(anim1);
img3.startAnimation(anim1);
img4.startAnimation(anim1);
img5.startAnimation(anim1);
img6.startAnimation(anim1);

Now, I want to hav a free small time between one animation and the other (let's say 200 ms), so that they will not start at the same time. I tried to add this.wait(200) between each of the startAnimation methods but this didn't work.

Any solution ?


Solution

  • The temporary solution that I found until now is:

    1. You need to re-define the same animation for each ImageView. Strange !
    2. Before you assign it to an ImageView, you will setStartOffset() for your animation by whatever you want.

    Wired But works fine !

    Thanks.