public class RotateDrawable extends DrawableWrapper
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.
Drawable.Callback, Drawable.ConstantState
Constructor and Description |
---|
RotateDrawable()
Creates a new rotating drawable with no wrapped drawable.
|
Modifier and Type | Method and Description |
---|---|
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() |
protected boolean |
onLevelChange(int level)
Override this in your subclass to change appearance if you vary based
on level.
|
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.
|
canApplyTheme, clearMutated, getAlpha, getChangingConfigurations, getConstantState, getDrawable, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getOpacity, getOpticalInsets, getOutline, getPadding, invalidateDrawable, isStateful, mutate, onBoundsChange, onLayoutDirectionChanged, onStateChange, scheduleDrawable, setAlpha, setColorFilter, setDrawable, setHotspot, setHotspotBounds, setTintList, setTintMode, setVisible, unscheduleDrawable
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getBounds, getCallback, getColorFilter, getCurrent, getDirtyBounds, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getState, getTransparentRegion, inflate, invalidateSelf, isAutoMirrored, isFilterBitmap, isProjected, isVisible, jumpToCurrentState, obtainAttributes, parseTintMode, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setLayoutDirection, setLevel, setState, setTint, setXfermode, unscheduleSelf
public RotateDrawable()
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme) throws XmlPullParserException, IOException
Drawable
inflate
in class DrawableWrapper
r
- Resources used to resolve attribute valuesparser
- XML parser from which to inflate this Drawableattrs
- Base set of attribute valuestheme
- Theme to apply, may be nullXmlPullParserException
IOException
public void applyTheme(Resources.Theme t)
Drawable
applyTheme
in class DrawableWrapper
t
- the theme to applypublic void draw(Canvas canvas)
Drawable
draw
in class DrawableWrapper
canvas
- The canvas to draw intopublic void setFromDegrees(float fromDegrees)
fromDegrees
- starting angle in degreesgetFromDegrees()
public float getFromDegrees()
setFromDegrees(float)
public void setToDegrees(float toDegrees)
toDegrees
- ending angle in degreesgetToDegrees()
public float getToDegrees()
setToDegrees(float)
public void setPivotX(float pivotX)
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.
pivotX
- X position around which to rotatesetPivotXRelative(boolean)
public float getPivotX()
setPivotX(float)
public void setPivotXRelative(boolean relative)
relative
- true if the X pivot represents a fraction of the drawable
width, or false if it represents an absolute value in pixelsisPivotXRelative()
public boolean isPivotXRelative()
setPivotXRelative(boolean)
public void setPivotY(float pivotY)
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.
pivotY
- Y position around which to rotategetPivotY()
public float getPivotY()
setPivotY(float)
public void setPivotYRelative(boolean relative)
relative
- True if the Y pivot represents a fraction of the drawable
height, or false if it represents an absolute value in pixelsisPivotYRelative()
public boolean isPivotYRelative()
setPivotYRelative(boolean)
protected boolean onLevelChange(int level)
Drawable
onLevelChange
in class DrawableWrapper