Added in API level 1

RotateAnimation


open class RotateAnimation : Animation

An animation that controls the rotation of an object. This rotation takes place in the X-Y plane. You can specify the point to use for the center of the rotation, where (0,0) is the top left point. If not specified, (0,0) is the default rotation point.

Summary

Inherited constants
Int ABSOLUTE

The specified dimension is an absolute number of pixels.

Int INFINITE

Repeat the animation indefinitely.

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.

Int RELATIVE_TO_SELF

The specified dimension holds a float and should be multiplied by the height or width of the object being animated.

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.

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).

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,android.view.animation.Transformation) is invoked for the first animation frame. This can is useful for short animations.

Int ZORDER_BOTTOM

Requests that the content being animated be forced under all other content for the duration of the animation.

Int ZORDER_NORMAL

Requests that the content being animated be kept in its current Z order.

Int ZORDER_TOP

Requests that the content being animated be forced on top of all other content for the duration of the animation.

Public constructors
RotateAnimation(context: Context!, attrs: AttributeSet!)

Constructor used when a RotateAnimation is loaded from a resource.

RotateAnimation(fromDegrees: Float, toDegrees: Float)

Constructor to use when building a RotateAnimation from code.

RotateAnimation(fromDegrees: Float, toDegrees: Float, pivotX: Float, pivotY: Float)

Constructor to use when building a RotateAnimation from code

RotateAnimation(fromDegrees: Float, toDegrees: Float, pivotXType: Int, pivotXValue: Float, pivotYType: Int, pivotYValue: Float)

Constructor to use when building a RotateAnimation from code

Public methods
open Unit
initialize(width: Int, height: Int, parentWidth: Int, parentHeight: Int)

Protected methods
open Unit
applyTransformation(interpolatedTime: Float, t: Transformation!)

Inherited functions
Unit cancel()

Cancel the animation. Cancelling an animation invokes the animation listener, if set, to notify the end of the animation. If you cancel an animation manually, you must call reset() before starting the animation again.

Animation clone()

Long computeDurationHint()

Compute a hint at how long the entire animation may last, in milliseconds. Animations can be written to cause themselves to run for a different duration than what is computed here, but generally this should be accurate.

Unit ensureInterpolator()

Gurantees that this animation has an interpolator. Will use a AccelerateDecelerateInterpolator is nothing else was specified.

Unit finalize()

Int getBackdropColor()

Returns the background color to show behind the animating windows. Will only show the background if showBackdrop was set to true. See setShowBackdrop(boolean).

Int getBackgroundColor()

Returns the background color behind the animation.

Boolean getDetachWallpaper()

Return value of setDetachWallpaper(boolean).

Long getDuration()

How long this animation should last

Boolean 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. If fillBefore is false and fillEnabled is true, the transformation will not be applied until the start time of the animation.

Interpolator! getInterpolator()

Gets the acceleration curve type for this animation.

Int getRepeatCount()

Defines how many times the animation should repeat. The default value is 0.

Int getRepeatMode()

Defines what this animation should do when it reaches the end.

Float getScaleFactor()

The scale factor is set by the call to getTransformation. Overrides of getTransformation(long,android.view.animation.Transformation,float) will get this value directly. Overrides of applyTransformation(float,android.view.animation.Transformation) can call this method to get the value.

Boolean getShowBackdrop()

If showBackdrop is true and this animation is applied on a window, then the windows in the animation will animate with the background associated with this window behind them. If no backdrop color is explicitly set, the backdrop's color comes from the android.R.styleable#Theme_colorBackground that is applied to this window through its theme. If multiple animating windows have showBackdrop set to true during an animation, the top most window with showBackdrop set to true and a valid background color takes precedence.

Long getStartOffset()

When this animation should start, relative to StartTime

Long getStartTime()

When this animation should start. If the animation has not startet yet, this method might return START_ON_FIRST_FRAME.

Boolean getTransformation(currentTime: Long, outTransformation: Transformation!)

Gets the transformation to apply at a specified point in time. Implementations of this method should always replace the specified Transformation or document they are doing otherwise.

Boolean getTransformation(currentTime: Long, outTransformation: Transformation!, scale: Float)

Gets the transformation to apply at a specified point in time. Implementations of this method should always replace the specified Transformation or document they are doing otherwise.

Int getZAdjustment()

Returns the Z ordering mode to use while running the animation as previously set by setZAdjustment.

Boolean hasEnded()

Indicates whether this animation has ended or not.

Boolean hasStarted()

Indicates whether this animation has started or not.

Boolean isFillEnabled()

If fillEnabled is true, this animation will apply the value of fillBefore.

Boolean isInitialized()

Whether or not the animation has been initialized.

Unit reset()

Reset the initialization state of this animation.

Float resolveSize(type: Int, value: Float, size: Int, parentSize: Int)

Convert the information in the description of a size to an actual dimension

Unit restrictDuration(durationMillis: Long)

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.

Unit scaleCurrentDuration(scale: Float)

How much to scale the duration by.

Unit setAnimationListener(listener: Animation.AnimationListener!)

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.

Unit setBackdropColor(backdropColor: Int)

Set the color to use for the backdrop shown behind the animating windows. Will only show the backdrop if showBackdrop was set to true. See setShowBackdrop(boolean).

Unit setBackgroundColor(bg: Int)

Set background behind animation.

Unit setDetachWallpaper(detachWallpaper: Boolean)

If detachWallpaper is true, and this is a window animation of a window that has a wallpaper background, then the window will be detached from the wallpaper while it runs. That is, the animation will only be applied to the window, and the wallpaper behind it will remain static.

Unit setDuration(durationMillis: Long)

How long this animation should last. The duration cannot be negative.

Unit setFillAfter(fillAfter: Boolean)

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 to individual animations and when using an to chain animations.

Unit setFillBefore(fillBefore: Boolean)

If fillBefore is true, this animation will apply its transformation before the start time of the animation. Defaults to true if setFillEnabled(boolean) is not set to true. Note that this applies when using an to chain animations. The transformation is not applied before the AnimationSet itself starts.

Unit setFillEnabled(fillEnabled: Boolean)

If fillEnabled is true, the animation will apply the value of fillBefore. Otherwise, fillBefore is ignored and the animation transformation is always applied until the animation ends.

Unit setInterpolator(context: Context!, resID: Int)

Sets the acceleration curve for this animation. The interpolator is loaded as a resource from the specified context.

Unit setInterpolator(i: Interpolator!)

Sets the acceleration curve for this animation. Defaults to a linear interpolation.

Unit setRepeatCount(repeatCount: Int)

Sets how many times the animation should be repeated. If the repeat count is 0, the animation is never repeated. If the repeat count is greater than 0 or INFINITE, the repeat mode will be taken into account. The repeat count is 0 by default.

Unit setRepeatMode(repeatMode: Int)

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.

Unit setShowBackdrop(showBackdrop: Boolean)

If showBackdrop is true and this animation is applied on a window, then the windows in the animation will animate with the background associated with this window behind them. If no backdrop color is explicitly set, the backdrop's color comes from the android.R.styleable#Theme_colorBackground that is applied to this window through its theme. If multiple animating windows have showBackdrop set to true during an animation, the top most window with showBackdrop set to true and a valid background color takes precedence.

Unit setStartOffset(startOffset: Long)

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.

Unit setStartTime(startTimeMillis: Long)

When this animation should start. When the start time is set to START_ON_FIRST_FRAME, the animation will start the first time getTransformation(long,android.view.animation.Transformation) is invoked. The time passed to this method should be obtained by calling AnimationUtils.currentAnimationTimeMillis() instead of System.currentTimeMillis().

Unit setZAdjustment(zAdjustment: Int)

Set the Z ordering mode to use while running the animation.

Unit start()

Convenience method to start the animation the first time getTransformation(long,android.view.animation.Transformation) is invoked.

Unit 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. For instance, a fade animation will not affect the bounds whereas a 200% scale animation will.

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 constructors

RotateAnimation

Added in API level 1
RotateAnimation(
    context: Context!,
    attrs: AttributeSet!)

Constructor used when a RotateAnimation is loaded from a resource.

Parameters
context Context!: Application context to use
attrs AttributeSet!: Attribute set from which to read values

RotateAnimation

Added in API level 1
RotateAnimation(
    fromDegrees: Float,
    toDegrees: Float)

Constructor to use when building a RotateAnimation from code. Default pivotX/pivotY point is (0,0).

Parameters
fromDegrees Float: Rotation offset to apply at the start of the animation.
toDegrees Float: Rotation offset to apply at the end of the animation.

RotateAnimation

Added in API level 1
RotateAnimation(
    fromDegrees: Float,
    toDegrees: Float,
    pivotX: Float,
    pivotY: Float)

Constructor to use when building a RotateAnimation from code

Parameters
fromDegrees Float: Rotation offset to apply at the start of the animation.
toDegrees Float: Rotation offset to apply at the end of the animation.
pivotX Float: The X coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the left edge.
pivotY Float: The Y coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the top edge.

RotateAnimation

Added in API level 1
RotateAnimation(
    fromDegrees: Float,
    toDegrees: Float,
    pivotXType: Int,
    pivotXValue: Float,
    pivotYType: Int,
    pivotYValue: Float)

Constructor to use when building a RotateAnimation from code

Parameters
fromDegrees Float: Rotation offset to apply at the start of the animation.
toDegrees Float: Rotation offset to apply at the end of the animation.
pivotXType Int: Specifies how pivotXValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.
pivotXValue Float: The X coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the left edge. This value can either be an absolute number if pivotXType is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.
pivotYType Int: Specifies how pivotYValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.
pivotYValue Float: The Y coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the top edge. This value can either be an absolute number if pivotYType is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.

Public methods

initialize

Added in API level 1
open fun initialize(
    width: Int,
    height: Int,
    parentWidth: Int,
    parentHeight: Int
): Unit
Parameters
width Int: Width of the object being animated
height Int: Height of the object being animated
parentWidth Int: Width of the animated object's parent
parentHeight Int: Height of the animated object's parent

Protected methods

applyTransformation

Added in API level 1
protected open fun applyTransformation(
    interpolatedTime: Float,
    t: Transformation!
): Unit
Parameters
interpolatedTime Float: The value of the normalized time (0.0 to 1.0) after it has been run through the interpolation function.
t Transformation!: The Transformation object to fill in with the current transforms.