Detecting when ValueAnimator is done

后端 未结 3 1703
清酒与你
清酒与你 2021-02-02 05:37

Right now I am detecting the end of my ValueAnimator by checking when the progress has reached 100...

//Setup the animation
ValueAnimator anim = ValueAnimator.of         


        
3条回答
  •  [愿得一人]
    2021-02-02 06:09

    You can do something like:

    ValueAnimator anim = ValueAnimator.ofInt(progress, seekBar.getMax());
    anim.setDuration(Utility.setAnimationDuration(progress));
    anim.addUpdateListener(new AnimatorUpdateListener() 
    {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) 
        {
            int animProgress = (Integer) animation.getAnimatedValue();
            seekBar.setProgress(animProgress);
        }
    });
    anim.addListener(new AnimatorListenerAdapter() 
    {
        @Override
        public void onAnimationEnd(Animator animation) 
        {
            // done
        }
    });
    anim.start();
    

提交回复
热议问题