Added in API level 1

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
draw(canvas: Canvas)

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
setPivotX(pivotX: Float)

Sets the X position around which the drawable is rotated.

open Unit

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

open Unit
setPivotY(pivotY: Float)

Sets the Y position around which the drawable is rotated.

open Unit

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

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

Added in API level 1
RotateDrawable()

Creates a new rotating drawable with no wrapped drawable.

Public methods

applyTheme

Added in API level 21
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

Added in API level 1
open fun draw(canvas: Canvas): Unit
Parameters
canvas Canvas: This value cannot be null.

getFromDegrees

Added in API level 21
open fun getFromDegrees(): Float
Return
Float starting angle for rotation in degrees

getPivotX

Added in API level 21
open fun getPivotX(): Float
Return
Float X position around which to rotate

getPivotY

Added in API level 21
open fun getPivotY(): Float
Return
Float Y position around which to rotate

getToDegrees

Added in API level 21
open fun getToDegrees(): Float
Return
Float ending angle for rotation in degrees

inflate

Added in API level 21
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

Added in API level 21
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

isPivotYRelative

Added in API level 21
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

setFromDegrees

Added in API level 21
open fun setFromDegrees(fromDegrees: Float): Unit

Sets the start angle for rotation.

Parameters
fromDegrees Float: starting angle in degrees

setPivotX

Added in API level 21
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

setPivotXRelative

Added in API level 21
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

setPivotY

Added in API level 21
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

Added in API level 21
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

setToDegrees

Added in API level 21
open fun setToDegrees(toDegrees: Float): Unit

Sets the end angle for rotation.

Parameters
toDegrees Float: ending angle in degrees

See Also

Protected methods

onLevelChange

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