您的位置:首页 > 移动开发 > Android开发

Android API 包解析02-android.animation

2016-06-24 15:22 369 查看

Interfaces 接口

Animator.AnimatorListener

动画监听器从一个动画接收通知消息。

Animator.AnimatorPauseListener A pause listener receives notifications from an animation when the animation is paused or resumed.

LayoutTransition.TransitionListener 此接口用来监听转变的开始事件与结束事件。

TimeAnimator.TimeListener 此接口实现可将自身设置为TimeAnimator实例的更新监听器并接受回调,在每一帧上获得自动画开始以来的时间和自上一帧以来的时间间隔。

TimeInterpolator 时间内插器定义了一个动画的变化的速率。

TypeEvaluator 使用setEvaluator(TypeEvaluator)功能需要的接口。

ValueAnimator.AnimatorUpdateListener 此接口实现可将自身设置为每一动画帧上ValueAnimator实例的更新监听器并接受回调, 当已经为该ValueAnimator计算出当前帧的值以后。

Classes 类

Animator 是那些具有启动、结束且包含AnimatorListeners的基础支持功能的类的超级类。

AnimatorInflater 此类用来将Animator XML文件实例化并注入Animator类。

AnimatorListenerAdapter 此适配器为Animator.AnimatorListener的方法提供了空的实现。

AnimatorSet 此类将一组Animator对象按指定的顺序播放。

AnimatorSet.Builder 为方便向AnimatorSet加入animation对象(连同不同animation对象之间的关系)工具类。

ArgbEvaluator 此计算器可作为类型内插器,于代表ARGB颜色的整型值之间。

FloatEvaluator 此计算器可作为类型内插器,于浮点型数值之间。

IntEvaluator 此计算器可作为类型内插器,于整型数值之间。

Keyframe 该类包含了一个animation类的time/value值对。

LayoutTransition 该类在 ViewGroup类中使得背景可以是自动的动画。

ObjectAnimator ValueAnimator的子类,提供了对目标对象的属性动画的支持。

PropertyValuesHolder 该类载有一个属性的信息,以及此属性在动画过程需要用到的值。

RectEvaluator This evaluator can be used to perform type interpolation between Rect values.

TimeAnimator 该类为已经与系统中所有其他动画对象同步的监听器提供一个简单的回调机制。

ValueAnimator 该类为运行中的动画对象提供一个简单的时间引擎,以便计算动画的值并将结果设置于目标对象。

AnimatorSet 动画集合

This class plays a set of Animator objects in the specified order. Animations can be set up to play together, in sequence, or after a specified delay.

这个类用来播放指定顺序的Animator对象动画集合.可以设置动画同时播放,按照顺序播放,或者延迟播放.

There are two different approaches to adding animations to a AnimatorSet: either the playTogether() or playSequentially() methods can be called to add a set of animations all at once, or the play(Animator) can be used in conjunction with methods in the Builder class to add animations one by one.

有两个不同性质的添加动画方法到 AnimatorSet中:

playTogether()或者playSequentially()方法用来一次添加一个动画集合,或者在Builder类中通过方法来一个个连接动画.

It is possible to set up a AnimatorSet with circular dependencies between its animations. For example, an animation a1 could be set up to start before animation a2, a2 before a3, and a3 before a1. The results of this configuration are undefined, but will typically result in none of the affected animations being played. Because of this (and because circular dependencies do not make logical sense anyway), circular dependencies should be avoided, and the dependency flow of animations should only be in one direction.

设置一个循环的动画集合是可以办到的,比如动画 a1能设置在a2之前,a2在a3之前,a3在a1之前.这个配置的结果是没有定义的,但典型的结果是没有受影响的动画也会播放.因为(并且因为循环依赖没有创建逻辑感官),应避免循环依赖,并且依赖流动画应该是单向的.

void cancel()

Cancels the animation.

Note that canceling a AnimatorSet also cancels all of the animations that it is responsible for.

AnimatorSet clone()

Creates and returns a copy of this Object.

void end()

Ends the animation.

Note that ending a AnimatorSet also ends all of the animations that it is responsible for.

ArrayList getChildAnimations()

Returns the current list of child Animator objects controlled by this AnimatorSet.

long getDuration()//获取动画时长

Gets the length of each of the child animations of this AnimatorSet.

TimeInterpolator getInterpolator()

Returns the timing interpolator that this animation uses.

long getStartDelay()

The amount of time, in milliseconds, to delay starting the animation after start() is called.

boolean isRunning()

Returns true if any of the child animations of this AnimatorSet have been started and have not yet ended.

boolean isStarted()

Returns whether this Animator has been started and not yet ended.

void pause()

Pauses a running animation.

AnimatorSet.Builder play(Animator anim)//播放,返回一个Builder,通过Builder可以设置动画的顺序。

This method creates a Builder object, which is used to set up playing constraints.

void playSequentially(Animator… items)//按照顺序播放

Sets up this AnimatorSet to play each of the supplied animations when the previous animation ends.

void playSequentially(List items)

Sets up this AnimatorSet to play each of the supplied animations when the previous animation ends.

void playTogether(Collection items)//同时播放属性动画

Sets up this AnimatorSet to play all of the supplied animations at the same time.

void playTogether(Animator… items)

Sets up this AnimatorSet to play all of the supplied animations at the same time.

void resume()

Resumes a paused animation, causing the animator to pick up where it left off when it was paused.

AnimatorSet setDuration(long duration)//设置时长

Sets the length of each of the current child animations of this AnimatorSet.

void setInterpolator(TimeInterpolator interpolator)//设置插补器

Sets the TimeInterpolator for all current child animations of this AnimatorSet.

void setStartDelay(long startDelay)//设置动画开始延时

The amount of time, in milliseconds, to delay starting the animation after start() is called.

void setTarget(Object target)//设置要播放动画的对象

Sets the target object for all current child animations of this AnimatorSet that take targets (ObjectAnimator and AnimatorSet).

void setupEndValues()

This method tells the object to use appropriate information to extract ending values for the animation.

void setupStartValues()

This method tells the object to use appropriate information to extract starting values for the animation.

void start()//开始播放动画.

Starts this animation.

Starting this AnimatorSet will, in turn, start the animations for which it is responsible.

AnimatorSet.Builder

这个类用来设置动画之间的关系,主要有下面4个方法

AnimatorSet.Builder after(Animator anim)

设置当前Builder对象在参数中anim对象之后播放

AnimatorSet.Builder after(long delay)

设置当前Builder对象在参数中delay延迟之后播放

AnimatorSet.Builder before(Animator anim)

设置当前Builder对象在参数中anim对象之前播放

AnimatorSet.Builder with(Animator anim)

设置当前Builder对象与参数中anim对象同时播放

For example, this sets up a AnimatorSet to play anim1 and anim2 at the same time, anim3 to play when anim2 finishes, and anim4 to play when anim3 finishes:

比如,同时播放anim1和anim2,anim2放完后播放anim3,再播放anim4:

AnimatorSet s = new AnimatorSet();
s.play(anim1).with(anim2);
s.play(anim2).before(anim3);
s.play(anim4).after(anim3);


Note in the example that both before(Animator) and after(Animator) are used. These are just different ways of expressing the same relationship and are provided to make it easier to say things in a way that is more natural, depending on the situation.

虽然方式不同,一个用了before,一个用了after,但结果是相同的.

It is possible to make several calls into the same Builder object to express multiple relationships. However, note that it is only the animation passed into the initial play(Animator) method that is the dependency in any of the successive calls to the Builder object. For example, the following code starts both anim2 and anim3 when anim1 ends; there is no direct dependency relationship between anim2 and anim3:

可以只用一个Builder来连接动画.播放anim1之后再同时播放anim2和anim3,注意,播放顺序是根据play方法设置的对象作为参考的.

AnimatorSet s = new AnimatorSet();

s.play(anim1).before(anim2).before(anim3);

If the desired result is to play anim1 then anim2 then anim3, this code expresses the relationship correctly:

如果想要按顺序播放应该这样写:

AnimatorSet s = new AnimatorSet();

s.play(anim1).before(anim2);

s.play(anim2).before(anim3);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: