Code example for ValueAnimator

Methods: addUpdateListener, setInterpolator

0
 
        private void createAnimation() { 
            if (bounceAnim == null) {
                bounceAnim = ObjectAnimator.ofFloat(ball, "y",
                        ball.getY(), getHeight() - BALL_SIZE).setDuration(1500);
                bounceAnim.setInterpolator(new BounceInterpolator());
                bounceAnim.addUpdateListener(this);
            } 
        } 
 
        public void startAnimation() { 
            createAnimation(); 
            bounceAnim.start();
        } 
 
        public void seek(long seekTime) {
            createAnimation(); 
            bounceAnim.setCurrentPlayTime(seekTime);
        } 
 
        private ShapeHolder addBall(float x, float y) {