Code example for TranslateAnimation

Methods: setAnimationListener, setDuration, setFillAfter, startAnimation

0
            if (!isAnimationFinished || mCurrentCardId == 0) return false; 
 
            final int count = mContainer.getChildCount(); 
            final View recycleView = mContainer.getChildAt(count - 1); 
 
            Animation hideAnimation = new TranslateAnimation(0, -mDisplayWidth, 0, -10); 
            hideAnimation.setDuration(250); 
            hideAnimation.setFillAfter(true); 
            hideAnimation.setAnimationListener(new Animation.AnimationListener() { 
                @Override 
                public void onAnimationStart(Animation animation) { 
                    isAnimationFinished = false; 
                } 
 
                @Override 
                public void onAnimationEnd(Animation animation) { 
                    mContainer.removeViewAt(count - 1); 
                    mContainer.addView(getCardView(), 0, mBottomLayer); 
                    mContainer.requestLayout(); 
                    isAnimationFinished = true; 
                    mCurrentCardId--; 
                } 
 
                @Override 
                public void onAnimationRepeat(Animation animation) { 
                } 
            }); 
 
            recycleView.clearAnimation(); 
            recycleView.startAnimation(hideAnimation); 
 
            mContainer.getChildAt(count - 2).clearAnimation(); 
            mContainer.getChildAt(count - 2).setLayoutParams(mTopLayer); 
            mContainer.getChildAt(count - 2).startAnimation(mOneStepUpAnimation);