android animation中interpolator參數詳解

  interpolator 被用來修飾動畫效果,定義動畫的變化率,可以使存在的動畫效果可以 accelerated(加速),decelerated(減速),repeated(重複),bounced(彈跳)等。

  android 自帶的interpolator:


AccelerateInterpolator     在動畫開始的地方速率改變比較慢,然後開始加速

DecelerateInterpolator    在動畫開始的地方快然後慢

AccelerateDecelerateInterpolator    在動畫開始與結束的地方速率改變比較慢,在中間的時候加速


AnticipateInterpolator   開始的時候向後然後向前甩

OvershootInterpolator    向前甩一定值後再回到原來位置

AnticipateOvershootInterpolator    開始時向後甩,結束時向前甩一定值後返回終點


BounceInterpolator    動畫結束的時候彈起

CycleInterpolator    動畫循環播放特定的次數,速率改變沿着正弦曲線

LinearInterpolator    以常量速率改變



對於 LinearInterpolator ,變化率是個常數,即 f (x) = x.
public float getInterpolation(float input) {
return input;
}

Interpolator其他的幾個子類,也都是按照特定的算法,實現了對變化率。還可以定義自己的 Interpolator 子類,實現拋物線、自由落體等物理效果。


如果android定義的interpolators不符合你的效果也可以自定義interpolators

例子:

XML file saved at res/anim/my_overshoot_interpolator.xml:

<?xml version="1.0" encoding="utf-8"?>
<overshootInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
    android:tension="7.0"
    />

 

android:shareInterpolator Boolean. "true" if you want to share the same interpolator among all child elements

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章