變化率是個常數,即 f (x) = x.
方法:public float getInterpolation(float input)
AccelerateInterpolator--開始變化很慢,然后逐漸變快,即 f(x) = x*x 或者 f(x) = pow(x, 2*mFactor).
方法:public float getInterpolation(float input)
AccelerateDecelerateInterpolator--變化率開始和結束都很慢,但中間很快,即 f(x) = (cos ((x+1)*PI) / 2.0f) + 0.5f.
方法:public float getInterpolation(float input)
LinearInerpolator、AccelerateInterpolator, DecelerateInterpolator, AccelerateDecelerateInterpolator,CycleInterpolator 是 Interpolator 的子類,分別實現了勻速、加速、減速、變速、循環等效果。
AlphaAnimation
控制透明度
構造函數:
@param開始的透明度
@param結束的透明度
AlphaAnimation(float fromAlpha, float toAlpha)
方法:
willChangeBounds() 具體不詳,不過其返回值是固定的都是false
willChangeTransformationMatrix() false
ScaleAnimation
控制尺寸
構造函數:
@param開始時x方向的伸縮比列
@param結束時x方向的伸縮比列
@param開始時y方向的伸縮比列
@param結束時y方向的伸縮比列
ScaleAnimation(float fromX, float toX, float fromY, float toY)
@param動畫在x軸的伸縮位置0%-100%中取值,50%為物件的X或Y方向坐標上的中點位置
@param動畫在y軸的伸縮位置
ScaleAnimation(float fromX, float toX, float fromY, float toY, float pivotX, float pivotY)
@param pivotXType動畫在X軸相對于物件位置類型--固定的一些數據
@param pivotYType動畫在X軸相對于物件位置類型
pivotXValue,pivotYValue同上面的pivotX,pivotY
ScaleAnimation(float fromX, float toX, float fromY, float toY,int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
方法:
initialize(int width, int height, int parentWidth, int parentHeight)設置動畫的大小根據父類的維數(猜測)
TranslateAnimation
移動
構造函數:
@param開始時x的位置
@param結束時x的位置
@param開始時y的位置
@param結束時y的位置
TranslateAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta)
@param參考上面ScaleAnimation的
TranslateAnimation(int fromXType, float fromXValue, int toXType, float toXValue,int fromYType, float fromYValue, int toYType, float toYValue)
方法:
@param同ScaleAnimation的
initialize(int width, int height, int parentWidth, int parentHeight)
RotateAnimation
旋轉
構造函數:
@param開始的角度
@param結束的角度
RotateAnimation(float fromDegrees, float toDegrees)
@param動畫在x軸的旋轉位置
@param動畫在x軸的旋轉位置
RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY)
方法:
@param同ScaleAnimation的
initialize(int width, int height, int parentWidth, int parentHeight)
Animation
抽象類,所有控制動畫的都繼承與該類
Aniamtion 是基類,他記錄了動畫的通用屬性和方法。主要的屬性包括動畫持續時間、重復次數、interpolator等。
方法:---只列舉了幾個方法,用法很簡單,可以去看sdk
getTransformation (currentTime, outTransformation)
該方法根據當前時間 (currentTime) 和 interpolator,計算當前的變換,在 outTransformation 中返回。
setRepeatMode(int)—在測試AnimationSet是該函數沒有成功,可能有什么地方設置錯了,以后再跟進
@param Animation.RESTART回到動作開始時的坐標,Animation.REVERSE反轉的意思,a->b,在從b->a,Animation.INFINITE不斷重復該動作
設置動作結束后,將怎樣處理,只有在repeatCount大于0或為INFINITE的時候setRepeatMode才會生效
TranslateAnimation、RotateAnimation、AlphaAnimation、ScaleAnimation等是Animation的子類,分別實現了平移、旋轉、改變透明度、縮放等動畫。
AnimationSet
設置一個動畫組,就是將一系列動作合在一起形成新的動畫
可以包含多個Animation,但都是在同一個時間執行的,是并行,不是串行執行的。如果AnimationSet中有一些設定,如duration,fillBefore等,它包含的子動作也設定了的話,子動作中的設定將會給覆蓋掉。
構造函數:
@param是否公用動畫插入器,為true表示共用AnimationSet的插入器
AnimationSet(boolean shareInterpolator)
方法:==
@param為true時將在播放完后被應用,播完后停在最后一幅畫上,這里重寫了Animation的該方法,其他的基本上都是直接使用父類的
setFillAfter(boolean fillAfter)
@param為true時將在開始前被應用,播完后停在第一幅畫上,好像不設置該屬性也會停留在最開始的那副上面
setFillBefore(boolean fillBefore)
@param在使用AnimationSet的重復mode時,還沒有看到有什么效果,但是它的解釋和Animation的該方法是一樣的
setRepeatMode(int repeatMode)
@param動畫停留時間間隔,從上次結束后停留多長時間進入下一次動畫
setStartOffset(long startOffset)
@param添加動畫
addAnimation(Animation a)
Example
AnimationSet aa = new AnimationSet(true);
Animation myAnimaton = new TranslateAnimation(0,100,0,100);
aa.addAnimation(myAnimaton);
Animation myAnimaton1 = new RotateAnimation(0,360);
aa.addAnimation(myAnimaton1);
myImage.startAnimation(aa);
aa.start();
aa.setDuration(2000);
aa.setFillAfter(true);
AnimationUtils
該類沒有父類,動畫的輔助類.構造函數也沒有,使用默認的
方法:
@param可以看到不需要實例化該對象就可以使用,通過資源xml獲得一個動畫
static Animation loadAnimation(Context context, int id)
TranslateAnimation manmation = (TranslateAnimation)AnimationUtils. loadAnimation(this,R.anim.animation);
@param
LayoutAnimationController loadLayoutAnimation(Context context, int id)
LayoutAnimationController
Layout animation controller is used to animated a layout's, or a view group's, children.
該類和其衍生類GridLayoutAnimationController,GridLayoutAnimationController.AnimationParameters等還沒有看到相關資料,也沒有用過
Animation.Description
Utility class to parse a string description of a size.
GridLayoutAnimationController
A layout animation controller is used to animated a grid layout's children.
GridLayoutAnimationController.AnimationParameters
The set of parameters that has to be attached to each view contained in the view group animated by the grid layout animation controller.
LayoutAnimationController.AnimationParameters
The set of parameters that has to be attached to each view contained in the view group animated by the layout animation controller.
Transformation
Defines the transformation to be applied at one point in time of an Animation.
在xml文件中設置動畫可以參考android_xml文件中介紹的,有實例解釋
AlphaAnimation
漸變透明度動畫效果
ScaleAnimation
漸變尺寸伸縮動畫效果
TranslateAnimation
畫面轉換位置移動動畫效果
RotateAnimation
畫面轉移旋轉動畫效果
transition設置兩張圖片的過渡,好像只能設置兩張之間的過渡,多設置幾張也只顯示前面兩張
本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/lishubing1126/archive/2009/12/02/4926770.aspx