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.
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
|
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:
Related methods:
Related methods:
Related methods:
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
.
RotateDrawable ()
Creates a new rotating drawable with no wrapped drawable.
void applyTheme (Resources.Theme t)
Applies the specified theme to this Drawable and its children.
Parameters | |
---|---|
t |
Resources.Theme :
the theme to apply
|
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
|
float getFromDegrees ()
Related XML Attributes:
Returns | |
---|---|
float |
starting angle for rotation in degrees |
See also:
float getPivotX ()
Related XML Attributes:
Returns | |
---|---|
float |
X position around which to rotate |
See also:
float getPivotY ()
Related XML Attributes:
Returns | |
---|---|
float |
Y position around which to rotate |
See also:
float getToDegrees ()
Related XML Attributes:
Returns | |
---|---|
float |
ending angle for rotation in degrees |
See also:
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 |
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:
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:
void setFromDegrees (float fromDegrees)
Sets the start angle for rotation.
Related XML Attributes:
Parameters | |
---|---|
fromDegrees |
float :
starting angle in degrees |
See also:
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:
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:
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:
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:
void setToDegrees (float toDegrees)
Sets the end angle for rotation.
Related XML Attributes:
Parameters | |
---|---|
toDegrees |
float :
ending angle in degrees |
See also:
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. |