Code example for ValueAnimator

Methods: addUpdateListenersetCurrentPlayTimesetInterpolator

0
 
        private void createAnimation() { 
            if (bounceAnim == null) {
                bounceAnim = ObjectAnimator.ofFloat(ball, "y", ball.getY(), getHeight() - 50f).
                        setDuration(1500); 
                bounceAnim.setInterpolator(new AccelerateInterpolator(2f));
                bounceAnim.addUpdateListener(this);
            } 
        } 
 
        public void startAnimation() { 
            createAnimation(); 
            bounceAnim.start();
        } 
 
        public void reverseAnimation() { 
            createAnimation(); 
            bounceAnim.reverse();
        } 
 
        public void seek(long seekTime) {
            createAnimation(); 
            bounceAnim.setCurrentPlayTime(seekTime);
        } 
 
        private ShapeHolder createBall(float x, float y) {
            OvalShape circle = new OvalShape();
            circle.resize(50f, 50f);
Stop searching for code, let great code find you!  Add Codota to your java IDE