Android APIs
public class

RotateDrawable

extends DrawableWrapper
java.lang.Object
   ↳ android.graphics.drawable.Drawable
     ↳ android.graphics.drawable.DrawableWrapper
       ↳ android.graphics.drawable.RotateDrawable

Class Overview

A Drawable that can rotate another Drawable based on the current level value. The start and end angles of rotation can be controlled to map any circular arc to the level values range.

It can be defined in an XML file with the <rotate> element. For more information, see the guide to Animation Resources.

Summary

XML Attributes
Attribute Name Related Method Description
android:drawable Reference to a drawable resource to use for the frame. 
android:fromDegrees setFromDegrees(float)  
android:pivotX setPivotX(float)  
android:pivotY setPivotY(float)  
android:toDegrees setToDegrees(float)  
android:visible Provides initial visibility state of the drawable; the default value is false. 
Public Constructors
RotateDrawable()
Creates a new rotating drawable with no wrapped drawable.
Public Methods
void applyTheme(Resources.Theme t)
Applies the specified theme to this Drawable and its children.
void draw(Canvas canvas)
Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).
float getFromDegrees()
float getPivotX()
float getPivotY()
float getToDegrees()
void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme)
Inflate this Drawable from an XML resource optionally styled by a theme.
boolean isPivotXRelative()
boolean isPivotYRelative()
void setFromDegrees(float fromDegrees)
Sets the start angle for rotation.
void setPivotX(float pivotX)
Sets the X position around which the drawable is rotated.
void setPivotXRelative(boolean relative)
Sets whether the X pivot value represents a fraction of the drawable width or an absolute value in pixels.
void setPivotY(float pivotY)
Sets the Y position around which the drawable is rotated.
void setPivotYRelative(boolean relative)
Sets whether the Y pivot value represents a fraction of the drawable height or an absolute value in pixels.
void setToDegrees(float toDegrees)
Sets the end angle for rotation.
Protected Methods
boolean onLevelChange(int level)
Override this in your subclass to change appearance if you vary based on level.
[Expand]
Inherited Methods
From class android.graphics.drawable.DrawableWrapper
From class android.graphics.drawable.Drawable
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback

XML Attributes

android:drawable

Reference to a drawable resource to use for the frame. If not given, the drawable must be defined by the first child tag.

Must be a reference to another resource, in the form "@[+][package:]type:name" or to a theme attribute in the form "?[package:][type:]name".

This corresponds to the global attribute resource symbol drawable.

Related Methods

android:fromDegrees

Related Methods

android:pivotX

Related Methods

android:pivotY

Related Methods

android:toDegrees

Related Methods

android:visible

Provides initial visibility state of the drawable; the default value is false. See setVisible(boolean, boolean).

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol visible.

Related Methods

Public Constructors

public RotateDrawable ()

Added in API level 1

Creates a new rotating drawable with no wrapped drawable.

Public Methods

public void applyTheme (Resources.Theme t)

Added in API level 21

Applies the specified theme to this Drawable and its children.

Parameters
t

public void draw (Canvas canvas)

Added in API level 1

Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).

Parameters
canvas The canvas to draw into

public float getFromDegrees ()

Added in API level 21

Related XML Attributes:

Returns
float starting angle for rotation in degrees

public float getPivotX ()

Added in API level 21

Related XML Attributes:

Returns
float X position around which to rotate

See also:

public float getPivotY ()

Added in API level 21

Related XML Attributes:

Returns
float Y position around which to rotate

See also:

public float getToDegrees ()

Added in API level 21

Related XML Attributes:

Returns
float ending angle for rotation in degrees

public void inflate (Resources r, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme)

Added in API level 21

Inflate this Drawable from an XML resource optionally styled by a theme.

Parameters
r Resources used to resolve attribute values
parser XML parser from which to inflate this Drawable
attrs Base set of attribute values
theme Theme to apply, may be null
Throws
XmlPullParserException
IOException

public boolean isPivotXRelative ()

Added in API level 21

Returns
boolean true if the X pivot represents a fraction of the drawable width, or false if it represents an absolute value in pixels

public boolean isPivotYRelative ()

Added in API level 21

Returns
boolean true if the Y pivot represents a fraction of the drawable height, or false if it represents an absolute value in pixels

public void setFromDegrees (float fromDegrees)

Added in API level 21

Sets the start angle for rotation.

Related XML Attributes:

Parameters
fromDegrees starting angle in degrees

See also:

public void setPivotX (float pivotX)

Added in API level 21

Sets the X position around which the drawable is rotated.

Related XML Attributes:

Parameters
pivotX X position around which to rotate. If the X pivot is relative, the position represents a fraction of the drawable width. Otherwise, the position represents an absolute value in pixels.

public void setPivotXRelative (boolean relative)

Added in API level 21

Sets whether the X pivot value represents a fraction of the drawable width or an absolute value in pixels.

Parameters
relative true if the X pivot represents a fraction of the drawable width, or false if it represents an absolute value in pixels

See also:

public void setPivotY (float pivotY)

Added in API level 21

Sets the Y position around which the drawable is rotated.

Related XML Attributes:

Parameters
pivotY Y position around which to rotate. If the Y pivot is relative, the position represents a fraction of the drawable height. Otherwise, the position represents an absolute value in pixels.

See also:

public void setPivotYRelative (boolean relative)

Added in API level 21

Sets whether the Y pivot value represents a fraction of the drawable height or an absolute value in pixels.

Parameters
relative True if the Y pivot represents a fraction of the drawable height, or false if it represents an absolute value in pixels

See also:

public void setToDegrees (float toDegrees)

Added in API level 21

Sets the end angle for rotation.

Related XML Attributes:

Parameters
toDegrees ending angle in degrees

See also:

Protected Methods

protected boolean onLevelChange (int level)

Added in API level 1

Override this in your subclass to change appearance if you vary based on level.

Parameters
level
Returns
boolean Returns true if the level change has caused the appearance of the Drawable to change (that is, it needs to be drawn), else false if it looks the same and there is no need to redraw it since its last level.