java.lang.Object
android.view.animation.Animation
public abstract class Animationextends Objectimplements Cloneable
Abstraction for an Animation that can be applied to Views, Surfaces, or other objects. See the animation package description file
.
嵌套类摘要 | |
---|---|
|
Animation.AnimationListener An animation listener receives notifications from an animation. |
字段摘要 | |
---|---|
static int |
ABSOLUTE The specified dimension is an absolute number of pixels. |
static int |
INFINITE Repeat the animation indefinitely. |
static 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. |
static int |
RELATIVE_TO_SELF The specified dimension holds a float and should be multiplied by the height or width of the object being animated. |
static 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. |
static 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). |
static 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. |
static int |
ZORDER_BOTTOM Requests that the content being animated be forced under all other content for the duration of the animation. |
static int |
ZORDER_NORMAL Requests that the content being animated be kept in its current Z order. |
static int |
ZORDER_TOP Requests that the content being animated be forced on top of all other content for the duration of the animation. |
构造方法摘要 | |
---|---|
Animation() Creates a new animation with a duration of 0ms, the default interpolator, with fillBefore set to true and fillAfter set to false |
|
Animation(Context context, AttributeSet attrs) Creates a new animation whose parameters come from the specified context and attributes set. |
方法摘要 | |
---|---|
long |
computeDurationHint() Compute a hint at how long the entire animation may last, in milliseconds. |
long |
getDuration() How long this animation should last |
boolea |
getFillAfter() If fillAfter is true, this animation will apply its transformation after the end time of the animation. |
boolean |
getFillBefore() If fillBefore is true, this animation will apply its transformation before the start time of the animation. |
Interpolator |
getInterpolator() Gets the acceleration curve type for this animation. |
void |
getInvalidateRegion(int left, int top, int right, int bottom, RectF invalidate, Transformation transformation) |
int |
getRepeatCount() Defines how many times the animation should repeat. |
int |
getRepeatMode() Defines what this animation should do when it reaches the end. |
long |
getStartOffset() When this animation should start, relative to StartTime |
long |
getStartTime() When this animation should start. |
boolean |
getTransformation(long currentTime, Transformation outTransformation) Gets the transformation to apply at a specified point in time. |
int |
getZAdjustment() Returns the Z ordering mode to use while running the animation as previously set by setZAdjustment(int). |
boolean |
hasEnded() Indicates whether this animation has ended or not. |
boolean |
hasStarted() Indicates whether this animation has started or not. |
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. |
void |
initializeInvalidateRegion(int left, int top, int right, int bottom) |
boolean |
isFillEnabled() If fillEnabled is true, this animation will apply fillBefore and fillAfter. |
boolean |
isInitialized() Whether or not the animation has been initialized. |
void |
reset() Reset the initialization state of this animation. |
void |
restrictDuration(long durationMillis) Ensure that the duration that this animation will run is not longer than durationMillis. |
void |
scaleCurrentDuration(float scale) How much to scale the duration by. |
void |
setAnimationListener(Animation.AnimationListener listener) Binds an animation listener to this animation. |
void |
setDuration(long durationMillis) How long this animation should last. |
void |
setFillAfter(boolean fillAfter) If fillAfter is true, the transformation that this animation performed will persist when it is finished. |
void |
setFillBefore(boolean fillBefore) If fillBefore is true, this animation will apply its transformation before the start time of the animation. |
void |
setFillEnabled(boolean fillEnabled) If fillEnabled is true, the animation will apply the value of fillBefore and fillAfter. |
void |
setInterpolator(Context context, int resID) Sets the acceleration curve for this animation. |
void |
setInterpolator(Interpolator i) Sets the acceleration curve for this animation. |
void |
setRepeatCount(int repeatCount) Sets how many times the animation should be repeated. |
void |
setRepeatMode(int repeatMode) Defines what this animation should do when it reaches the end. |
void |
setStartOffset(long startOffset) When this animation should start relative to the start time. |
void |
setStartTime(long startTimeMillis) When this animation should start. |
void |
setZAdjustment(int zAdjustment) Set the Z ordering mode to use while running the animation. |
void |
start() Convenience method to start the animation the first time getTransformation(long, Transformation) is invoked. |
void |
startNow() Convenience method to start the animation at the current time in milliseconds. |
boolean |
willChangeBounds() Indicates whether or not this animation will affect the bounds of the animated view. |
boolean |
willChangeTransformationMatrix() Indicates whether or not this animation will affect the transformation matrix. |
从类 java.lang.Object 继承的方法 |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
字段详细信息 |
---|
public static final int INFINITE
public static final int RESTART
public static final int REVERSE
public static final int START_ON_FIRST_FRAME
public static final int ABSOLUTE
public static final int RELATIVE_TO_SELF
public static final int RELATIVE_TO_PARENT
public static final int ZORDER_NORMAL
public static final int ZORDER_TOP
public static final int ZORDER_BOTTOM
构造方法详细信息 |
---|
public Animation()
public Animation(Context context, AttributeSet attrs)
context
- the application environment
attrs
- the set of attributes holding the animation parameters
方法详细信息 |
---|
public void reset()
public boolean isInitialized()
public void initialize(int width, int height, int parentWidth, int parentHeight)
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, android.view.animation.Transformation).
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 setInterpolator(Context context, int resID)
context
- The application environment
resID
- The resource identifier of the interpolator to load
public void setInterpolator(Interpolator i)
i
- The interpolator which defines the acceleration curve
public void setStartOffset(long startOffset)
startOffset
- When this Animation should start, in milliseconds from the start time of the root AnimationSet.
public void setDuration(long durationMillis)
durationMillis
- Duration in milliseconds
public void restrictDuration(long durationMillis)
durationMillis
- The maximum duration the animation is allowed to run.
public void scaleCurrentDuration(float scale)
scale
- The amount to scale the duration.
public void setStartTime(long startTimeMillis)
startTimeMillis
- the start time in milliseconds
public void start()
public void startNow()
public void setRepeatMode(int repeatMode)
repeatMode
- RESTART or REVERSE
public void setRepeatCount(int repeatCount)
repeatCount
- the number of times the animation should be repeated
public boolean isFillEnabled()
public void setFillEnabled(boolean fillEnabled)
fillEnabled
- true if the animation should take fillBefore and fillAfter into account
public void setFillBefore(boolean fillBefore)
fillBefore
- true if the animation should apply its transformation before it starts
public void setFillAfter(boolean fillAfter)
fillAfter
- true if the animation should apply its transformation after it ends
public void setZAdjustment(int zAdjustment)
zAdjustment
- The desired mode, one of ZORDER_NORMAL, ZORDER_TOP, or ZORDER_BOTTOM.
public Interpolator getInterpolator()
public long getStartTime()
public long getDuration()
public long getStartOffset()
public int getRepeatMode()
public int getRepeatCount()
public boolean getFillBefore()
public boolean getFillAfter()
public int getZAdjustment()
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.
public boolean willChangeBounds()
Indicates whether or not this animation will affect the bounds of the animated view. For instance, a fade animation will not affect the bounds whereas a 200% scale animation will.
public void setAnimationListener(Animation.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.
listener
- the animation listener to be notified
public long computeDurationHint()
public boolean getTransformation(long currentTime, Transformation outTransformation)
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.
public boolean hasStarted()
Indicates whether this animation has started or not.
public boolean hasEnded()
Indicates whether this animation has ended or not.
public void getInvalidateRegion(int left, int top, int right, int bottom, RectF invalidate, Transformation transformation)
left
-
top
-
right
-
bottom
-
invalidate
-
transformation
-
public void initializeInvalidateRegion(int left, int top, int right, int bottom)
left
-
top
-
right
-
bottom
-