Most visited

Recently visited

Added in API level 1

RotateDrawable

public class RotateDrawable
extends DrawableWrapper

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


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

android:drawable Reference to a drawable resource to use for the frame. 
android:fromDegrees  
android:pivotX  
android:pivotY  
android:toDegrees  
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.

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.

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.

Public constructors

RotateDrawable

Added in API level 1
RotateDrawable ()

Creates a new rotating drawable with no wrapped drawable.

Public methods

applyTheme

Added in API level 21
void applyTheme (Resources.Theme t)

Applies the specified theme to this Drawable and its children.

Parameters
t Resources.Theme: the theme to apply

draw

Added in API level 1
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).

Parameters
canvas Canvas: The canvas to draw into

getFromDegrees

Added in API level 21
float getFromDegrees ()

Related XML Attributes:

Returns
float starting angle for rotation in degrees

See also:

getPivotX

Added in API level 21
float getPivotX ()

Related XML Attributes:

Returns
float X position around which to rotate

See also:

getPivotY

Added in API level 21
float getPivotY ()

Related XML Attributes:

Returns
float Y position around which to rotate

See also:

getToDegrees

Added in API level 21
float getToDegrees ()

Related XML Attributes:

Returns
float ending angle for rotation in degrees

See also:

inflate

Added in API level 21
void inflate (Resources r, 
                XmlPullParser parser, 
                AttributeSet attrs, 
                Resources.Theme theme)

Inflate this Drawable from an XML resource optionally styled by a theme. This can't be called more than once for each Drawable. Note that framework may have called this once to create the Drawable instance from XML resource.

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

isPivotXRelative

Added in API level 21
boolean isPivotXRelative ()

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

See also:

isPivotYRelative

Added in API level 21
boolean isPivotYRelative ()

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

See also:

setFromDegrees

Added in API level 21
void setFromDegrees (float fromDegrees)

Sets the start angle for rotation.

Related XML Attributes:

Parameters
fromDegrees float: starting angle in degrees

See also:

setPivotX

Added in API level 21
void setPivotX (float pivotX)

Sets the X position around which the drawable is rotated.

If the X pivot is relative (as specified by setPivotXRelative(boolean)), then the position represents a fraction of the drawable width. Otherwise, the position represents an absolute value in pixels.

Related XML Attributes:

Parameters
pivotX float: X position around which to rotate

See also:

setPivotXRelative

Added in API level 21
void setPivotXRelative (boolean relative)

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

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

See also:

setPivotY

Added in API level 21
void setPivotY (float pivotY)

Sets the Y position around which the drawable is rotated.

If the Y pivot is relative (as specified by setPivotYRelative(boolean)), then the position represents a fraction of the drawable height. Otherwise, the position represents an absolute value in pixels.

Related XML Attributes:

Parameters
pivotY float: Y position around which to rotate

See also:

setPivotYRelative

Added in API level 21
void setPivotYRelative (boolean relative)

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

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

See also:

setToDegrees

Added in API level 21
void setToDegrees (float toDegrees)

Sets the end angle for rotation.

Related XML Attributes:

Parameters
toDegrees float: ending angle in degrees

See also:

Protected methods

onLevelChange

Added in API level 1
boolean onLevelChange (int level)

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

Parameters
level int
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.

Hooray!