Code example for AnimatorSet

Methods: addListener, playTogether, setDuration, setInterpolator

0
 
                    if (set != null && set.isRunning()) { 
                        set.cancel(); 
                    } 
 
                    set = new AnimatorSet(); 
                    set.playTogether(testOut, testIn); 
                    set.setInterpolator(interpolatorMap.get(spinner.getSelectedItem())); 
                    set.addListener(new Animator.AnimatorListener() { 
 
                        @Override 
                        public void onAnimationStart(Animator animation) {
                            componentOne.setVisibility(View.VISIBLE);
                            componentOne.setTranslationY(componentOne
                                    .getHeight());
                        } 
 
                        @Override 
                        public void onAnimationRepeat(Animator animation) {
                        } 
 
                        @Override 
                        public void onAnimationEnd(Animator animation) {
                            componentTwo.setVisibility(View.GONE);
 
                        } 
 
                        @Override 
                        public void onAnimationCancel(Animator animation) {
                            componentTwo.setVisibility(View.GONE);
                            componentTwo.setTranslationY(componentTwo
                                    .getHeight());
                            componentOne.setTranslationY(0);
 
                        } 
                    }); 
                     
                    set.setDuration(3000).start();
 
                } 
 
                componentOneVisible = !componentOneVisible; 
            }