幾種常用的Interpolator(插值器)的動畫效果


在實現動畫的非線性變化的方法中,常用的一種是為動畫添加插值器以改變視圖的屬性值,從而實現理想的動畫效果。Interpolator使用相對簡單,下面就只給出一些提供的插值器的默認效果。


在代碼中:直接調用setInterpolator(new AccelerateInterpolator());

在xml中:android:interpolator="@android:anim/accelerate_interpolator"
如果幾個動畫共用一個插值器,則:
android:shareInterpolator="true"
或者AnimatorSet調用setInterpolator


一個插值器不僅可以用於位移中,也可用在其他動畫或者疊加動畫效果中,其變化率如都遵循同一個函數公式。如下為插值器默認的公式,演示的圖片由於裁剪問題可能有偏差。

BounceInterpolator:
x * x * 8.0,               (x < 0.3535)
(x-0.54719)* (x-0.54719)* 8+0.7,   (x < 0.7408)
(x-0.8526)* (x-0.8526)* 8+0.9,    (x < 0.9644)
(x-1.0435)* (x-1.0435)* 8+0.95    (x = 其他)



AnticipateInterpolator:
x * x * ((2+ 1) * x - 2)



AccelerateDecelerateInterpolator:
(cos((x+ 1) * π) / 2.0) + 0.5

 

AccelerateInterpolator:

pow(x,2)

 

 

AnticipateOvershootInterpolator:
0.5*2*x * 2*x * ((3 + 1) * 2*x - 3)             (0 < x < 0.5)
0.5*((2*x-2) * (2*x-2) * ((3 + 1) * (2*x-2) + 3)+2)  (0.5 <= x < 1.0)


DecelerateInterpolator:
1.0 - pow((1.0 - x), 2 * 1)

 
 

LinearInterpolator:
x

 

 

OvershootInterpolator:
(x-1) * (x-1) * ((2+ 1) *( x-1) + 2)+1


CycleInterpolator:
sin(2 * 1* π * x)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM