星期日, 1月 22, 2012

Animation (四)

Android 應用程式學筆記

API Overview

你可以在android.animation中找到大部分的屬性動畫系統,因為在andorid.view.animation中已定義了許多interpolator了,你可以在屬性動畫系統使用這些interpolator,以下表格描述了屬性動畫系統主要的組件。

Animator類別提供建立動畫的基礎架構。正常來說你不需要直接使用到animator類別,它只提供延伸支持全部的動畫的最小的功能。以下為繼承自animator的類別。


Table 1. Animators
ClassDescription
ValueAnimatorThe main timing engine for property animation that also computes the values for the property to be animated. It has all of the core functionality that calculates animation values and contains the timing details of each animation, information about whether an animation repeats, listeners that receive update events, and the ability to set custom types to evaluate. There are two pieces to animating properties: calculating the animated values and setting those values on the object and property that is being animated. ValueAnimator does not carry out the second piece, so you must listen for updates to values calculated by the ValueAnimator and modify the objects that you want to animate with your own logic. See the section about Animating with ValueAnimator for more information.
ObjectAnimatorA subclass of ValueAnimator that allows you to set a target object and object property to animate. This class updates the property accordingly when it computes a new value for the animation. You want to use ObjectAnimator most of the time, because it makes the process of animating values on target objects much easier. However, you sometimes want to use ValueAnimator directly because ObjectAnimator has a few more restrictions, such as requiring specific acessor methods to be present on the target object.
AnimatorSetProvides a mechanism to group animations together so that they run in relation to one another. You can set animations to play together, sequentially, or after a specified delay. See the section about Choreographing multiple animations with Animator Sets for more information.

Evaluator告訴屬性動畫系統如何計算屬性的數值,它們用Animator類別提供的時序的資料,動畫起始和結束的數值,並根據這些數據計算動畫的屬性數值。以下為屬性動畫系統的evaluator。


Table 2. Evaluators
Class/InterfaceDescription
IntEvaluatorThe default evaluator to calculate values for int properties.
FloatEvaluatorThe default evaluator to calculate values for float properties.
ArgbEvaluatorThe default evaluator to calculate values for color properties that are represented as hexidecimal values.
TypeEvaluatorAn interface that allows you to create your own evaluator. If you are animating an object property that is not an intfloat, or color, you must implement the TypeEvaluator interface to specify how to compute the object property's animated values. You can also specify a customTypeEvaluator for intfloat, and color values as well, if you want to process those types differently than the default behavior. See the section about Using a TypeEvaluator for more information on how to write a custom evaluator.


TimeInterpolator定義如何在動畫中的數值作為工的能時序,例如,你可以指定整個動畫為線性,或者你可以動畫為非線性的,例如,在動畫開始為加速,動畫結束時減速。表三顯示在android.view.animation中的interpolator。如果沒有合適你需要的interpolator,你可以實現TimeInterpolator介面和創建你自己的。你可以在Using interpolators文章中了解更多資訊與如何自定義interpolator。


Table 3. Interpolators
Class/InterfaceDescription
AccelerateDecelerateInterpolatorAn interpolator whose rate of change starts and ends slowly but accelerates through the middle.
AccelerateInterpolatorAn interpolator whose rate of change starts out slowly and then accelerates.
AnticipateInterpolatorAn interpolator whose change starts backward then flings forward.
AnticipateOvershootInterpolatorAn interpolator whose change starts backward, flings forward and overshoots the target value, then finally goes back to the final value.
BounceInterpolatorAn interpolator whose change bounces at the end.
CycleInterpolatorAn interpolator whose animation repeats for a specified number of cycles.
DecelerateInterpolatorAn interpolator whose rate of change starts out quickly and and then decelerates.
LinearInterpolatorAn interpolator whose rate of change is constant.
OvershootInterpolatorAn interpolator whose change flings forward and overshoots the last value then comes back.
TimeInterpolatorAn interface that allows you to implement your own interpolator.

沒有留言:

張貼留言