android.view.animation
public
abstract
class
android.view.animation.Animation
Summary
Constants
| |
|
|
Value |
|
| int |
ABSOLUTE |
The specified dimension is an absolute number of pixels. |
0 |
0x00000000 |
| int |
NO_REPEAT |
Don't do anything when the animation ends. |
0 |
0x00000000 |
| 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 |
REPEAT |
Replay the animation from the beginning. |
1 |
0x00000001 |
| int |
REVERSE |
Replay the animation backwards (then forwards again). |
2 |
0x00000002 |
Fields
Public Constructors
Public Methods
Protected Methods
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait
Details
Constants
public
static
final
int
ABSOLUTE
The specified dimension is an absolute number of pixels.
Constant Value:
0
(0x00000000)
public
static
final
int
NO_REPEAT
Don't do anything when the animation ends.
Constant Value:
0
(0x00000000)
public
static
final
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.
Constant Value:
2
(0x00000002)
public
static
final
int
RELATIVE_TO_SELF
The specified dimension holds a float and should be multiplied by the
height or width of the object being animated.
Constant Value:
1
(0x00000001)
public
static
final
int
REPEAT
Replay the animation from the beginning. Will
repeat indefinitely.
Constant Value:
1
(0x00000001)
public
static
final
int
REVERSE
Replay the animation backwards (then forwards again).
Will repeat indefinitely.
Constant Value:
2
(0x00000002)
Fields
protected
boolean
mCycleFlip
protected
long
mDurationMillis
protected
boolean
mFillAfter
protected
boolean
mFillBefore
protected
boolean
mInitialized
protected
int
mRepeatMode
protected
long
mStartOffsetMillis
protected
long
mStartTimeMillis
protected
boolean
mStarted
Public Constructors
Public Methods
public
long
getDuration()
How long this animation should last
Returns
- the duration in milliseconds of the animation
public
boolean
getFillAfter()
If fillAfter is true, this animation will apply its transformation
after the end time of the animation.
Returns
- true if the animation applies its transformation after it ends
public
boolean
getFillBefore()
If fillBefore is true, this animation will apply its transformation
before the start time of the animation.
Returns
- true if the animation applies its transformation before it starts
public
Interpolator
getInterpolator()
Gets the acceleration curve type for this animation.
public
int
getRepeatMode()
Defines what this animation should do when it reaches the end.
public
long
getStartOffset()
When this animation should start, relative to StartTime
Returns
- the start offset in milliseconds
public
long
getStartTime()
When this animation was started
Returns
- the time in milliseconds when the animation was started
public
boolean
getTransformation(long currentTime, Transformation outTransformation)
Gets the transformation to apply at a specified point in time
Parameters
| currentTime
| Where we are in the animation. This is wall clock
time. |
| outTransformation
| 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
boolean
isEnded()
Indicates whether this animation has ended or not.
Returns
- true if the animation has ended, false otherwise
public
boolean
isInitialized()
Whether or not the animation has been initialized.
Returns
- Has this animation been initialized.
public
boolean
isStarted()
Indicates whether this animation has started or not.
Returns
- true if the animation has started, false otherwise
public
void
reset()
Reset the initialization state of this animation.
public
void
scaleCurrentDuration(float scale)
How much to scale the duration by.
Parameters
| scale
| The amount to scale the duration.
|
public
void
setAnimationListener(AnimationListener listener)
Binds an animation listener to this animation. The animation listener
is notified of animation events such as the end of the animation or the
repetition of the animation.
Parameters
| listener
| the animation listener to be notified
|
public
void
setDuration(long durationMillis)
How long this animation should last.
Parameters
| durationMillis
| Duration in milliseconds
|
public
void
setFillAfter(boolean fillAfter)
If fillAfter is true, the transformation that this animation performed
will persist when it is finished. Defaults to true 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
setInterpolator(Context context, int resID)
Sets the acceleration curve for this animation. The interpolator is loaded as
a resource from the specified context.
Parameters
| context
| The application environment |
| resID
| The resource identifier of the interpolator to load
|
public
void
setInterpolator(Interpolator i)
Sets the acceleration curve for this animation. Defaults to a linear
interpolation.
Parameters
| i
| The interpolator which defines the acceleration curve
|
public
void
setRepeatMode(int repeatMode)
Defines what this animation should do when it reaches the end.
Defaults to NO_REPEAT
Parameters
| repeatMode
| One of NO_REPEAT, REPEAT, or REVERSE
|
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)
public
void
startNow()
Convenience method to start the animation at the current time in
milliseconds.
public
boolean
willChangeTargetViewBounds()
Indicates whether or not this animation will affect the current
bounds of the target view. For instance, a fade animation will not
affect the bounds whereas a scale animation will.
Returns
- true if this animation will change the bounds of the target view
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
Protected Methods
protected
void
applyTransformation(float interpolatedTime, Transformation t)
Helper for getTransformation. Subclasses should implement this to apply
their transforms given an interpolation value.
Parameters
| interpolatedTime
| The value of the normalized time (0.0 to 1.0)
after it has been run through the interpolation function. |
| t
| The Transofrmation object to fill in with the current
transforms.
|
protected
void
ensureInterpolator()
Gurantees that this animation has an interpolator. Will use
a AccelerateDecelerateInterpolator is nothing else was specified.
protected
float
resolveSize(int type, float value, int size, int parentSize)
Convert the information in the description of a size to an actual
dimension
Parameters
| type
| One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or
Animation.RELATIVE_TO_PARENT. |
| value
| The dimension associated with the type parameter |
| size
| The size of the object being animated |
| parentSize
| The size of the parent of the object being animated |
Returns
- The dimension to use for the animation