Android Animation詳解一

講解anroid.view.animation


Animation

Abstraction for an Animation that can be applied to Views, Surfaces, or other objects. See the animation package description file.
public abstract class Animation implements Cloneable {...}

該類是一個抽象類,實現Cloneable,可以clone克隆。它的子類包括AlphaAnimation, AnimationSet, RotateAnimation, ScaleAnimation, TranslateAnimation。

AlphaAnimation

RotateAnimation
ScaleAnimation
TranslateAnimation

AnimationSet
Represents a group of Animations that should be played together。
Constructor to use when building an AnimationSet from code
Parameters:
shareInterpolator Pass true if all of the animations in this set should use the interpolator associated with this AnimationSet. Pass false if each animation should use its own interpolator.
AnimationSet(boolean shareInterpolator)。

Interpolator
<span style="font-size:12px;">public interface Interpolator extends TimeInterpolator{...}</span>
被用來修飾動畫效果,定義動畫的變化率,可以使存在的動畫效果accelerated(加速),decelerated(減速),repeated(重複),bounced(彈跳)等。

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

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

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

AnticipateOvershootInterpolator
開始的時候向後然後向前甩一定值後返回最後的值

BounceInterpolator
動畫結束的時候彈起

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

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

LinearInterpolator
以常量速率改變

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

Transformation

在繪製Tween動畫的時候用的,Tween動畫的實質就是ParentView不斷的調整childView的Canvas的座標來實現的,在dispathdraw()中,Animation a = ChildView.getAnimation();Transformation tm = a.getTransformation(); //Transformation 中包含一個矩陣和 alpha 值,矩陣是用來做平移、旋轉和縮放動畫的,通過tm來設置子控件的canvas。

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