我們可以在xml里面設(shè)置屬性
//設(shè)置動(dòng)畫為加速動(dòng)畫(動(dòng)畫播放中越來越快)
android:interpolator="@android:anim/accelerate_interpolator"
//設(shè)置動(dòng)畫為減速動(dòng)畫(動(dòng)畫播放中越來越慢)
android:interpolator="@android:anim/decelerate_interpolator"
//設(shè)置動(dòng)畫為先加速在減速(開始速度最快 逐漸減慢)
android:interpolator="@android:anim/accelerate_decelerate_interpolator"
//先反向執(zhí)行一段,然后再加速反向回來(相當(dāng)于我們彈簧,先反向壓縮一小段赦拘,然后在加速彈出)
android:interpolator="@android:anim/anticipate_interpolator"
//同上先反向一段,然后加速反向回來奔垦,執(zhí)行完畢自帶回彈效果(更形象的彈簧效果)
android:interpolator="@android:anim/anticipate_overshoot_interpolator"
//執(zhí)行完畢之后會(huì)回彈跳躍幾段(相當(dāng)于我們高空掉下一顆皮球差凹,到地面是會(huì)跳動(dòng)幾下)
android:interpolator="@android:anim/bounce_interpolator"
//循環(huán),動(dòng)畫循環(huán)一定次數(shù)厅须,值的改變?yōu)橐徽液瘮?shù):Math.sin(2* mCycles* Math.PI* input)
android:interpolator="@android:anim/cycle_interpolator"
//線性均勻改變
android:interpolator="@android:anim/linear_interpolator"
//加速執(zhí)行仿畸,結(jié)束之后回彈
android:interpolator="@android:anim/overshoot_interpolator"
然后我們?cè)诖a中也可以設(shè)置,順序效果同上
animation.setInterpolator(new AccelerateInterpolator());
animation.setInterpolator(new DecelerateInterpolator());
animation.setInterpolator(new AccelerateDecelerateInterpolator());
animation.setInterpolator(new AnticipateInterpolator());
animation.setInterpolator(new AnticipateOvershootInterpolator());
animation.setInterpolator(new BounceInterpolator());
animation.setInterpolator(new CycleInterpolator(2));
animation.setInterpolator(new LinearInterpolator());
animation.setInterpolator(new OvershootInterpolator());
動(dòng)畫不設(shè)置Interpolator屬性即為默認(rèn)值九杂,勻速
Interpolator屬性也可自定義
轉(zhuǎn)自:https://www.cnblogs.com/onone/articles/6588335.html