android.view.animation.AnimationSet
Represents a group of Animations that should be played together.
The transformation of each individual animation are composed
together into a single transform.
If AnimationSet sets any properties that its children also set
(for example, duration or fillBefore), the values of AnimationSet
override the child values.
Summary
|
|
|
Value |
|
int |
ABSOLUTE |
The specified dimension is an absolute number of pixels. |
0 |
0x00000000 |
int |
INFINITE |
Repeat the animation indefinitely. |
-1 |
0xffffffff |
int |
RELATIVE_TO_PARENT |
The specified dimension holds a float and should be multiplied by the
height or width of the parent of the object being animated. |
2 |
0x00000002 |
int |
RELATIVE_TO_SELF |
The specified dimension holds a float and should be multiplied by the
height or width of the object being animated. |
1 |
0x00000001 |
int |
RESTART |
When the animation reaches the end and the repeat count is INFINTE_REPEAT
or a positive value, the animation restarts from the beginning. |
1 |
0x00000001 |
int |
REVERSE |
When the animation reaches the end and the repeat count is INFINTE_REPEAT
or a positive value, the animation plays backward (and then forward again). |
2 |
0x00000002 |
int |
START_ON_FIRST_FRAME |
Can be used as the start time to indicate the start time should be the current
time when getTransformation(long, Transformation) is invoked for the
first animation frame. |
-1 |
0xffffffff |
int |
ZORDER_BOTTOM |
Requests that the content being animated be forced under all other
content for the duration of the animation. |
-1 |
0xffffffff |
int |
ZORDER_NORMAL |
Requests that the content being animated be kept in its current Z
order. |
0 |
0x00000000 |
int |
ZORDER_TOP |
Requests that the content being animated be forced on top of all other
content for the duration of the animation. |
1 |
0x00000001 |
Public Constructors
Public Methods
applyTransformation,
ensureInterpolator,
getDuration,
getFillAfter,
getFillBefore,
getInterpolator,
getRepeatCount,
getRepeatMode,
getStartOffset,
getStartTime,
getTransformation,
getZAdjustment,
hasEnded,
hasStarted,
initialize,
isInitialized,
reset,
resolveSize,
restrictDuration,
scaleCurrentDuration,
setAnimationListener,
setDuration,
setFillAfter,
setFillBefore,
setInterpolator,
setInterpolator,
setRepeatCount,
setRepeatMode,
setStartOffset,
setStartTime,
setZAdjustment,
start,
startNow,
willChangeBounds,
willChangeTransformationMatrix
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Public Constructors
Constructor used whan an AnimationSet is loaded from a resource.
Parameters
context
| Application context to use |
attrs
| Attribute set from which to read values
|
public
AnimationSet(boolean shareInterpolator)
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 assocciated with this AnimationSet.
Pass false if each animation should use its own interpolator.
|
Public Methods
public
void
addAnimation(Animation a)
Add a child animation to this animation set.
The transforms of the child animations are applied in the order
that they were added
Returns
- All the child animations in this AnimationSet. Note that
this may include other AnimationSets, which are not expanded.
public
long
getDuration()
The duration of an AnimationSet is defined to be the
duration of the longest child animation.
Returns
- the duration in milliseconds of the animation
public
long
getStartTime()
When this animation should start. If the animation has not startet yet,
this method might return
START_ON_FIRST_FRAME.
public
boolean
getTransformation(long currentTime, Transformation t)
The transformation of an animation set is the concatenation of all of its
component animations.
Parameters
currentTime
| Where we are in the animation. This is wall clock time. |
t
| A tranformation object that is provided by the
caller and will be filled in by the animation. |
Returns
- True if the animation is still running
public
void
initialize(int width, int height, int parentWidth, int parentHeight)
Initialize this animation with the dimensions of the object being
animated as well as the objects parents. (This is to support animation
sizes being specifed relative to these dimensions.)
Objects that interpret a Animations should call this method when
the sizes of the object being animated and its parent are known, and
before calling getTransformation(long, Transformation).
Parameters
width
| Width of the object being animated |
height
| Height of the object being animated |
parentWidth
| Width of the animated object's parent |
parentHeight
| Height of the animated object's parent
|
public
void
restrictDuration(long durationMillis)
Ensure that the duration that this animation will run is not longer
than
durationMillis. In addition to adjusting the duration
itself, this ensures that the repeat count also will not make it run
longer than the given time.
Parameters
durationMillis
| The maximum duration the animation is allowed
to run.
|
public
void
scaleCurrentDuration(float scale)
How much to scale the duration by.
Parameters
scale
| The amount to scale the duration.
|
public
void
setDuration(long durationMillis)
Sets the duration of every child animation.
Parameters
durationMillis
| the duration of the animation, in milliseconds, for
every child in this set
|
public
void
setFillAfter(boolean fillAfter)
If fillAfter is true, the transformation that this animation performed
will persist when it is finished. Defaults to false if not set.
Note that this applies when using an
AnimationSet to chain
animations. The transformation is not applied before the AnimationSet
itself starts.
Parameters
fillAfter
| true if the animation should apply its transformation after it ends |
public
void
setFillBefore(boolean fillBefore)
If fillBefore is true, this animation will apply its transformation
before the start time of the animation. Defaults to false if not set.
Note that this applies when using an
AnimationSet to chain
animations. The transformation is not applied before the AnimationSet
itself starts.
Parameters
fillBefore
| true if the animation should apply its transformation before it starts |
public
void
setRepeatMode(int repeatMode)
Defines what this animation should do when it reaches the end. This
setting is applied only when the repeat count is either greater than
0 or
INFINITE. Defaults to
RESTART.
public
void
setStartOffset(long startOffset)
When this animation should start relative to the start time. This is most
useful when composing complex animations using an
AnimationSet
where some of the animations components start at different times.
Parameters
startOffset
| When this Animation should start, in milliseconds from
the start time of the root AnimationSet. |
public
void
setStartTime(long startTimeMillis)
Sets the start time of this animation and all child animations
Parameters
startTimeMillis
| the start time in milliseconds
|
public
boolean
willChangeTransformationMatrix()
Indicates whether or not this animation will affect the transformation
matrix. For instance, a fade animation will not affect the matrix whereas
a scale animation will.
Returns
- true if this animation will change the transformation matrix