RotateDrawable
open class RotateDrawable : DrawableWrapper
kotlin.Any | |||
↳ | 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 | |
---|---|
Creates a new rotating drawable with no wrapped drawable. |
Public methods | |
---|---|
open Unit |
Applies the specified theme to this Drawable and its children. |
open Unit | |
open Float | |
open Float | |
open Float | |
open Float | |
open Unit |
inflate(r: Resources, parser: XmlPullParser, attrs: AttributeSet, theme: Resources.Theme?) Inflate this Drawable from an XML resource optionally styled by a theme. |
open Boolean | |
open Boolean | |
open Unit |
setFromDegrees(fromDegrees: Float) Sets the start angle for rotation. |
open Unit |
Sets the X position around which the drawable is rotated. |
open Unit |
setPivotXRelative(relative: Boolean) Sets whether the X pivot value represents a fraction of the drawable width or an absolute value in pixels. |
open Unit |
Sets the Y position around which the drawable is rotated. |
open Unit |
setPivotYRelative(relative: Boolean) Sets whether the Y pivot value represents a fraction of the drawable height or an absolute value in pixels. |
open Unit |
setToDegrees(toDegrees: Float) Sets the end angle for rotation. |
Protected methods | |
---|---|
open Boolean |
onLevelChange(level: Int) |
Inherited functions | |
---|---|
XML attributes
android:drawable
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.
May be a reference to another resource, in the form "@[+][package:]type/name
" or a theme attribute in the form "?[package:]type/name
".
android:fromDegrees
android:fromDegrees
android:pivotX
android:pivotX
android:pivotY
android:pivotY
android:toDegrees
android:toDegrees
android:visible
android:visible
Provides initial visibility state of the drawable; the default value is false. See android.graphics.drawable.Drawable#setVisible
.
May be a boolean value, such as "true
" or "false
".
Public constructors
RotateDrawable
RotateDrawable()
Creates a new rotating drawable with no wrapped drawable.
Public methods
applyTheme
open fun applyTheme(t: Resources.Theme): Unit
Applies the specified theme to this Drawable and its children.
Parameters | |
---|---|
t |
Resources.Theme: This value cannot be null . |
draw
open fun draw(canvas: Canvas): Unit
Parameters | |
---|---|
canvas |
Canvas: This value cannot be null . |
getFromDegrees
open fun getFromDegrees(): Float
Return | |
---|---|
Float |
starting angle for rotation in degrees |
See Also
getPivotX
open fun getPivotX(): Float
Return | |
---|---|
Float |
X position around which to rotate |
See Also
getPivotY
open fun getPivotY(): Float
Return | |
---|---|
Float |
Y position around which to rotate |
See Also
getToDegrees
open fun getToDegrees(): Float
Return | |
---|---|
Float |
ending angle for rotation in degrees |
See Also
inflate
open fun inflate(
r: Resources,
parser: XmlPullParser,
attrs: AttributeSet,
theme: Resources.Theme?
): Unit
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: This value cannot be null . |
parser |
XmlPullParser: This value cannot be null . |
attrs |
AttributeSet: This value cannot be null . |
theme |
Resources.Theme?: This value may be null . |
Exceptions | |
---|---|
org.xmlpull.v1.XmlPullParserException |
|
java.io.IOException |
isPivotXRelative
open fun isPivotXRelative(): Boolean
Return | |
---|---|
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
open fun isPivotYRelative(): Boolean
Return | |
---|---|
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
open fun setFromDegrees(fromDegrees: Float): Unit
Sets the start angle for rotation.
Parameters | |
---|---|
fromDegrees |
Float: starting angle in degrees |
See Also
setPivotX
open fun setPivotX(pivotX: Float): Unit
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.
Parameters | |
---|---|
pivotX |
Float: X position around which to rotate |
See Also
setPivotXRelative
open fun setPivotXRelative(relative: Boolean): Unit
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
open fun setPivotY(pivotY: Float): Unit
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.
Parameters | |
---|---|
pivotY |
Float: Y position around which to rotate |
See Also
setPivotYRelative
open fun setPivotYRelative(relative: Boolean): Unit
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
open fun setToDegrees(toDegrees: Float): Unit
Sets the end angle for rotation.
Parameters | |
---|---|
toDegrees |
Float: ending angle in degrees |
See Also
Protected methods
onLevelChange
protected open fun onLevelChange(level: Int): Boolean
Return | |
---|---|
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. |