在网上找的一段滑动动画效果代码
- /**
- *定义从右侧进入的动画效果
- *@return
- */
- protectedAnimationinFromRightAnimation(){
- AnimationinFromRight=newTranslateAnimation(
- Animation.RELATIVE_TO_PARENT,+1.0f,
- Animation.RELATIVE_TO_PARENT,0.0f,
- Animation.RELATIVE_TO_PARENT,0.0f,
- Animation.RELATIVE_TO_PARENT,0.0f);
- inFromRight.setDuration(500);
- inFromRight.setInterpolator(newAccelerateInterpolator());
- returninFromRight;
- }
- /**
- *定义从左侧退出的动画效果
- *@return
- */
- protectedAnimationoutToLeftAnimation(){
- AnimationouttoLeft=newTranslateAnimation(
- Animation.RELATIVE_TO_PARENT,0.0f,
- Animation.RELATIVE_TO_PARENT,-1.0f,
- Animation.RELATIVE_TO_PARENT,0.0f,
- Animation.RELATIVE_TO_PARENT,0.0f);
- outtoLeft.setDuration(500);
- outtoLeft.setInterpolator(newAccelerateInterpolator());
- returnouttoLeft;
- }
- /**
- *定义从左侧进入的动画效果
- *@return
- */
- protectedAnimationinFromLeftAnimation(){
- AnimationinFromLeft=newTranslateAnimation(
- Animation.RELATIVE_TO_PARENT,-1.0f,
- Animation.RELATIVE_TO_PARENT,0.0f,
- Animation.RELATIVE_TO_PARENT,0.0f,
- Animation.RELATIVE_TO_PARENT,0.0f);
- inFromLeft.setDuration(500);
- inFromLeft.setInterpolator(newAccelerateInterpolator());
- returninFromLeft;
- }
- /**
- *定义从右侧退出时的动画效果
- *@return
- */
- protectedAnimationoutToRightAnimation(){
- AnimationouttoRight=newTranslateAnimation(
- Animation.RELATIVE_TO_PARENT,0.0f,
- Animation.RELATIVE_TO_PARENT,+1.0f,
- Animation.RELATIVE_TO_PARENT,0.0f,
- Animation.RELATIVE_TO_PARENT,0.0f);
- outtoRight.setDuration(500);
- outtoRight.setInterpolator(newAccelerateInterpolator());
- returnouttoRight;
- }