Android APIs
public class

RotateAnimation

extends Animation
java.lang.Object
   ↳ android.view.animation.Animation
     ↳ android.view.animation.RotateAnimation

Class Overview

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

[Expand]
Inherited XML Attributes
From class android.view.animation.Animation
[Expand]
Inherited Constants
From class android.view.animation.Animation
Public Constructors
RotateAnimation(Context context, AttributeSet attrs)
Constructor used when a RotateAnimation is loaded from a resource.
RotateAnimation(float fromDegrees, float toDegrees)
Constructor to use when building a RotateAnimation from code.
RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY)
Constructor to use when building a RotateAnimation from code
RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
Constructor to use when building a RotateAnimation from code
Public Methods
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.
Protected Methods
void applyTransformation(float interpolatedTime, Transformation t)
Helper for getTransformation.
[Expand]
Inherited Methods
From class android.view.animation.Animation
From class java.lang.Object

Public Constructors

public RotateAnimation (Context context, AttributeSet attrs)

Added in API level 1

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

public RotateAnimation (float fromDegrees, float toDegrees)

Added in API level 1

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.

public RotateAnimation (float fromDegrees, float toDegrees, float pivotX, float pivotY)

Added in API level 1

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.

public RotateAnimation (float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)

Added in API level 1

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

public void initialize (int width, int height, int parentWidth, int parentHeight)

Added in API level 1

Initialize this animation with the dimensions of the object being animated as well as the objects parents. (This is to support animation sizes being specified relative to these dimensions.)

Objects that interpret 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 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

protected void applyTransformation (float interpolatedTime, Transformation t)

Added in API level 1

Helper for getTransformation. Subclasses should implement this to apply their transforms given an interpolation value. Implementations of this method should always replace the specified Transformation or document they are doing otherwise.

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.