动画差值器
- AccelerateDecelerateInterpolator //中间速度加快
- AccelerateInterpolator //加速
- DecelerateInterpolator //减速
- AnticipateInterpolator //后退一点再加速
- OvershootInterpolator //减速到终点,超出终点一点
- AnticipateOvershootInterpolator //左右缓冲
- BounceInterpolator //弹球效果
- CycleInterpolator //左右摆动
- LinearInterpolator //匀速运动
DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay() .getMetrics(metrics); int widthPixels = metrics.widthPixels; //获取屏幕的宽度 //创建平移动画 TranslateAnimation animation = new TranslateAnimation(0, widthPixels / 2, 0, 0); animation.setDuration(2000); animation.setFillAfter(true); //animation.setRepeatCount(3); //animation.setRepeatMode(Animation.REVERSE); //中间速度加快 //创建差值器对象 AccelerateDecelerateInterpolator interpolator = new AccelerateDecelerateInterpolator(); //设置差值器 animation.setInterpolator(interpolator); //开始动画 mIv.startAnimation(animation);