1

I want show animation in my application, and i want show this animation each 3000m/s.
I write below code, but in this code show just once.

new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
        YoYo.with(Techniques.Bounce)
                .duration(1500)
                .playOn(arrowHelpImage);
    }
}, 3000);

How can i edit my code and show each 3000m/s ?

Dr. KoK
  • 13
  • 3

2 Answers2

0

U could use something like this. change the animations used below. this animations will run infinite. provide animation on end Listner. Change animation duration to 3000ms and use this in handler.it will work

YoYo.with(Techniques.Bounce)
    .duration(1200) 
    .interpolate(new AccelerateDecelerateInterpolator())
    .withListener(new Animator.AnimatorListener() {

        @Override 
        public void onAnimationStart(Animator animation) {}

        @Override 
        public void onAnimationEnd(Animator animation) {
          YoYo.with(Techniques.Bounce)
          .duration(1200) 
          .interpolate(new AccelerateDecelerateInterpolator())
          .withListener(this).playOn(arrowHelpImage);
       }

        @Override 
        public void onAnimationCancel(Animator animation) {}

        @Override 
        public void onAnimationRepeat(Animator animation) {}
    }).playOn(arrowHelpImage);
Victor
  • 4,171
  • 1
  • 29
  • 37
0

Put below code in your class.

private Handler handler;
private Runnable runnable;

below code in you oncreate

 handler = new Handler();
        runnable = new Runnable() {
            @Override
            public void run() {


 YoYo.with(Techniques.Bounce)
                .duration(1500)
                .playOn(arrowHelpImage);
                 handler.postDelayed(runnable, Constants.SPLASH_DURATION);
            }
        };
        handler.postDelayed(runnable, Constants.SPLASH_DURATION);


@Override
protected void onDestroy() {
    super.onDestroy();
    //Close the handler and the process of splash screen.
    if (handler != null && runnable != null) {
        handler.removeCallbacks(runnable);
    }
}
Mavya Soni
  • 932
  • 7
  • 15