Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Inherited XML Attrs](https://developer.android.com/reference/android/view/animation/RotateAnimation#inhattrs) \| [Inherited Constants](https://developer.android.com/reference/android/view/animation/RotateAnimation#inhconstants) \| [Ctors](https://developer.android.com/reference/android/view/animation/RotateAnimation#pubctors) \| [Methods](https://developer.android.com/reference/android/view/animation/RotateAnimation#pubmethods) \| [Protected Methods](https://developer.android.com/reference/android/view/animation/RotateAnimation#promethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/animation/RotateAnimation#inhmethods)

# RotateAnimation

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/view/animation/RotateAnimation "View this page in Kotlin") \|Java


`
public


class
RotateAnimation
`


`


`

`

extends https://developer.android.com/reference/android/view/animation/Animation


`

`


`

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.view.animation.Animation](https://developer.android.com/reference/android/view/animation/Animation) ||
|   | ↳ | android.view.animation.RotateAnimation |

<br />

*** ** * ** ***

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 XML attributes |
|---|---|
| From class `https://developer.android.com/reference/android/view/animation/Animation` |---|---| | [`android:backdropColor`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:backdropColor) | Special option for window animations: whether the window's background should be used as a background to the animation. | | [`android:detachWallpaper`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:detachWallpaper) | Special option for window animations: if this window is on top of a wallpaper, don't animate the wallpaper with it. | | [`android:duration`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:duration) | Amount of time (in milliseconds) for the animation to run. | | [`android:fillAfter`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:fillAfter) | When set to true, the animation transformation is applied after the animation is over. | | [`android:fillBefore`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:fillBefore) | When set to true or when fillEnabled is not set to true, the animation transformation is applied before the animation has started. | | [`android:fillEnabled`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:fillEnabled) | When set to true, the value of fillBefore is taken into account. | | [`android:interpolator`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:interpolator) | Defines the interpolator used to smooth the animation movement in time. | | [`android:repeatCount`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:repeatCount) | Defines how many times the animation should repeat. | | [`android:repeatMode`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:repeatMode) | Defines the animation behavior when it reaches the end and the repeat count is greater than 0 or infinite. | | [`android:showBackdrop`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:showBackdrop) | Special option for window animations: whether to show a background behind the animating windows. | | [`android:startOffset`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:startOffset) | Delay in milliseconds before the animation runs, once start time is reached. | | [`android:zAdjustment`](https://developer.android.com/reference/android/view/animation/Animation#attr_android:zAdjustment) | Allows for an adjustment of the Z ordering of the content being animated for the duration of the animation. | ||

| ### Inherited constants |
|---|
| From class `https://developer.android.com/reference/android/view/animation/Animation` |---|---| | `int` | `https://developer.android.com/reference/android/view/animation/Animation#ABSOLUTE` The specified dimension is an absolute number of pixels. | | `int` | `https://developer.android.com/reference/android/view/animation/Animation#INFINITE` Repeat the animation indefinitely. | | `int` | `https://developer.android.com/reference/android/view/animation/Animation#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` | `https://developer.android.com/reference/android/view/animation/Animation#RELATIVE_TO_SELF` The specified dimension holds a float and should be multiplied by the height or width of the object being animated. | | `int` | `https://developer.android.com/reference/android/view/animation/Animation#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` | `https://developer.android.com/reference/android/view/animation/Animation#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` | `https://developer.android.com/reference/android/view/animation/Animation#START_ON_FIRST_FRAME` Can be used as the start time to indicate the start time should be the current time when `https://developer.android.com/reference/android/view/animation/Animation#getTransformation(long,%20android.view.animation.Transformation)` is invoked for the first animation frame. | | `int` | `https://developer.android.com/reference/android/view/animation/Animation#ZORDER_BOTTOM` Requests that the content being animated be forced under all other content for the duration of the animation. | | `int` | `https://developer.android.com/reference/android/view/animation/Animation#ZORDER_NORMAL` Requests that the content being animated be kept in its current Z order. | | `int` | `https://developer.android.com/reference/android/view/animation/Animation#ZORDER_TOP` Requests that the content being animated be forced on top of all other content for the duration of the animation. | |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/animation/RotateAnimation#RotateAnimation(android.content.Context,%20android.util.AttributeSet)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/android/util/AttributeSet attrs) ` Constructor used when a RotateAnimation is loaded from a resource. |
| ` https://developer.android.com/reference/android/view/animation/RotateAnimation#RotateAnimation(float,%20float)(float fromDegrees, float toDegrees) ` Constructor to use when building a RotateAnimation from code. |
| ` https://developer.android.com/reference/android/view/animation/RotateAnimation#RotateAnimation(float,%20float,%20float,%20float)(float fromDegrees, float toDegrees, float pivotX, float pivotY) ` Constructor to use when building a RotateAnimation from code |
| ` https://developer.android.com/reference/android/view/animation/RotateAnimation#RotateAnimation(float,%20float,%20int,%20float,%20int,%20float)(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) ` Constructor to use when building a RotateAnimation from code |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/view/animation/RotateAnimation#initialize(int,%20int,%20int,%20int)(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` | ` https://developer.android.com/reference/android/view/animation/RotateAnimation#applyTransformation(float,%20android.view.animation.Transformation)(float interpolatedTime, https://developer.android.com/reference/android/view/animation/Transformation t) ` Helper for getTransformation. |

| ### Inherited methods |
|---|---|
| From class ` https://developer.android.com/reference/android/view/animation/Animation ` |---|---| | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#applyTransformation(float,%20android.view.animation.Transformation)(float interpolatedTime, https://developer.android.com/reference/android/view/animation/Transformation t) ` Helper for getTransformation. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#cancel()() ` Cancel the animation. | | ` https://developer.android.com/reference/android/view/animation/Animation` | ` https://developer.android.com/reference/android/view/animation/Animation#clone()() ` Creates and returns a copy of this object. | | ` long` | ` https://developer.android.com/reference/android/view/animation/Animation#computeDurationHint()() ` Compute a hint at how long the entire animation may last, in milliseconds. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#ensureInterpolator()() ` Gurantees that this animation has an interpolator. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` int` | ` https://developer.android.com/reference/android/view/animation/Animation#getBackdropColor()() ` Returns the background color to show behind the animating windows. | | ` int` | ` https://developer.android.com/reference/android/view/animation/Animation#getBackgroundColor()() ` *This method was deprecated in API level 30. None of window animations are running with background color.* | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#getDetachWallpaper()() ` *This method was deprecated in API level 29. All window animations are running with detached wallpaper.* | | ` long` | ` https://developer.android.com/reference/android/view/animation/Animation#getDuration()() ` How long this animation should last | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#getFillAfter()() ` If fillAfter is true, this animation will apply its transformation after the end time of the animation. | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#getFillBefore()() ` If fillBefore is true, this animation will apply its transformation before the start time of the animation. | | ` https://developer.android.com/reference/android/view/animation/Interpolator` | ` https://developer.android.com/reference/android/view/animation/Animation#getInterpolator()() ` Gets the acceleration curve type for this animation. | | ` int` | ` https://developer.android.com/reference/android/view/animation/Animation#getRepeatCount()() ` Defines how many times the animation should repeat. | | ` int` | ` https://developer.android.com/reference/android/view/animation/Animation#getRepeatMode()() ` Defines what this animation should do when it reaches the end. | | ` float` | ` https://developer.android.com/reference/android/view/animation/Animation#getScaleFactor()() ` The scale factor is set by the call to `getTransformation`. | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#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. | | ` long` | ` https://developer.android.com/reference/android/view/animation/Animation#getStartOffset()() ` When this animation should start, relative to StartTime | | ` long` | ` https://developer.android.com/reference/android/view/animation/Animation#getStartTime()() ` When this animation should start. | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#getTransformation(long,%20android.view.animation.Transformation,%20float)(long currentTime, https://developer.android.com/reference/android/view/animation/Transformation outTransformation, float scale) ` Gets the transformation to apply at a specified point in time. | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#getTransformation(long,%20android.view.animation.Transformation)(long currentTime, https://developer.android.com/reference/android/view/animation/Transformation outTransformation) ` Gets the transformation to apply at a specified point in time. | | ` int` | ` https://developer.android.com/reference/android/view/animation/Animation#getZAdjustment()() ` Returns the Z ordering mode to use while running the animation as previously set by `https://developer.android.com/reference/android/view/animation/Animation#setZAdjustment(int)`. | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#hasEnded()() ` <br /> Indicates whether this animation has ended or not. | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#hasStarted()() ` <br /> Indicates whether this animation has started or not. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#initialize(int,%20int,%20int,%20int)(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. | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#isFillEnabled()() ` If fillEnabled is true, this animation will apply the value of fillBefore. | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#isInitialized()() ` Whether or not the animation has been initialized. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#reset()() ` Reset the initialization state of this animation. | | ` float` | ` https://developer.android.com/reference/android/view/animation/Animation#resolveSize(int,%20float,%20int,%20int)(int type, float value, int size, int parentSize) ` Convert the information in the description of a size to an actual dimension | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#restrictDuration(long)(long durationMillis) ` Ensure that the duration that this animation will run is not longer than <var translate="no">durationMillis</var>. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#scaleCurrentDuration(float)(float scale) ` How much to scale the duration by. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setAnimationListener(android.view.animation.Animation.AnimationListener)(https://developer.android.com/reference/android/view/animation/Animation.AnimationListener listener) ` <br /> Binds an animation listener to this animation. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setBackdropColor(int)(int backdropColor) ` Set the color to use for the backdrop shown behind the animating windows. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setBackgroundColor(int)(int bg) ` *This method was deprecated in API level 30. None of window animations are running with background color.* | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setDetachWallpaper(boolean)(boolean detachWallpaper) ` *This method was deprecated in API level 29. All window animations are running with detached wallpaper.* | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setDuration(long)(long durationMillis) ` How long this animation should last. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setFillAfter(boolean)(boolean fillAfter) ` If fillAfter is true, the transformation that this animation performed will persist when it is finished. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setFillBefore(boolean)(boolean fillBefore) ` If fillBefore is true, this animation will apply its transformation before the start time of the animation. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setFillEnabled(boolean)(boolean fillEnabled) ` If fillEnabled is true, the animation will apply the value of fillBefore. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setInterpolator(android.view.animation.Interpolator)(https://developer.android.com/reference/android/view/animation/Interpolator i) ` Sets the acceleration curve for this animation. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setInterpolator(android.content.Context,%20int)(https://developer.android.com/reference/android/content/Context context, int resID) ` Sets the acceleration curve for this animation. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setRepeatCount(int)(int repeatCount) ` Sets how many times the animation should be repeated. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setRepeatMode(int)(int repeatMode) ` Defines what this animation should do when it reaches the end. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setShowBackdrop(boolean)(boolean showBackdrop) ` 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. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setStartOffset(long)(long startOffset) ` When this animation should start relative to the start time. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setStartTime(long)(long startTimeMillis) ` When this animation should start. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#setZAdjustment(int)(int zAdjustment) ` Set the Z ordering mode to use while running the animation. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#start()() ` Convenience method to start the animation the first time `https://developer.android.com/reference/android/view/animation/Animation#getTransformation(long,%20android.view.animation.Transformation)` is invoked. | | ` void` | ` https://developer.android.com/reference/android/view/animation/Animation#startNow()() ` Convenience method to start the animation at the current time in milliseconds. | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#willChangeBounds()() ` <br /> Indicates whether or not this animation will affect the bounds of the animated view. | | ` boolean` | ` https://developer.android.com/reference/android/view/animation/Animation#willChangeTransformationMatrix()() ` <br /> Indicates whether or not this animation will affect the transformation matrix. | ||
| From class ` https://developer.android.com/reference/java/lang/Object ` |---|---| | ` https://developer.android.com/reference/java/lang/Object` | ` https://developer.android.com/reference/java/lang/Object#clone()() ` Creates and returns a copy of this object. | | ` boolean` | ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Indicates whether some other object is "equal to" this one. | | ` void` | ` https://developer.android.com/reference/java/lang/Object#finalize()() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. | | ` final https://developer.android.com/reference/java/lang/Class<?>` | ` https://developer.android.com/reference/java/lang/Object#getClass()() ` Returns the runtime class of this `Object`. | | ` int` | ` https://developer.android.com/reference/java/lang/Object#hashCode()() ` Returns a hash code value for the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notify()() ` Wakes up a single thread that is waiting on this object's monitor. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#notifyAll()() ` Wakes up all threads that are waiting on this object's monitor. | | ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/Object#toString()() ` Returns a string representation of the object. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed. | | ` final void` | ` https://developer.android.com/reference/java/lang/Object#wait()() ` Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*. | ||

## Public constructors

### RotateAnimation

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public RotateAnimation (Context context, 
                AttributeSet attrs)
```

Constructor used when a RotateAnimation is loaded from a resource.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: Application context to use <br /> |
| `attrs` | `AttributeSet`: Attribute set from which to read values <br /> |

### RotateAnimation

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public RotateAnimation (float fromDegrees, 
                float toDegrees)
```

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

<br />

| Parameters ||
|---|---|
| `fromDegrees` | `float`: Rotation offset to apply at the start of the animation. <br /> |
| `toDegrees` | `float`: Rotation offset to apply at the end of the animation. <br /> |

### RotateAnimation

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Constructor to use when building a RotateAnimation from code

<br />

| Parameters ||
|---|---|
| `fromDegrees` | `float`: Rotation offset to apply at the start of the animation. <br /> |
| `toDegrees` | `float`: Rotation offset to apply at the end of the animation. <br /> |
| `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. <br /> |
| `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. <br /> |

### RotateAnimation

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Constructor to use when building a RotateAnimation from code

<br />

| Parameters ||
|---|---|
| `fromDegrees` | `float`: Rotation offset to apply at the start of the animation. <br /> |
| `toDegrees` | `float`: Rotation offset to apply at the end of the animation. <br /> |
| `pivotXType` | `int`: Specifies how pivotXValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT. <br /> |
| `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. <br /> |
| `pivotYType` | `int`: Specifies how pivotYValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT. <br /> |
| `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. <br /> |

## Public methods

### initialize

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
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 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 `https://developer.android.com/reference/android/view/animation/Animation#getTransformation(long,%20android.view.animation.Transformation)`.

<br />

| Parameters ||
|---|---|
| `width` | `int`: Width of the object being animated <br /> |
| `height` | `int`: Height of the object being animated <br /> |
| `parentWidth` | `int`: Width of the animated object's parent <br /> |
| `parentHeight` | `int`: Height of the animated object's parent <br /> |

## Protected methods

### applyTransformation

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
protected void applyTransformation (float interpolatedTime, 
                Transformation t)
```

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.

<br />

| Parameters ||
|---|---|
| `interpolatedTime` | `float`: The value of the normalized time (0.0 to 1.0) after it has been run through the interpolation function. <br /> |
| `t` | `Transformation`: The Transformation object to fill in with the current transforms. <br /> |