AnimatedStateListDrawableCompat
open class AnimatedStateListDrawableCompat : StateListDrawable, TintAwareDrawable
androidx.appcompat.graphics.drawable.AnimatedStateListDrawableCompat |
A Drawable
providing animated transitions between states.
A port of android.graphics.drawable.AnimatedStateListDrawable
compatible with older versions of the platform.
This drawable can be defined in an XML file with the <animated-selector>
element. Each keyframe Drawable is defined in a nested <item>
element. Transitions are defined in a nested <transition>
element.
Notable exceptions not supported by this class:
drawable
s defined as children of<item>
s or<transition>
s (except vectors) ignore theme attributes prior to API level 21- Animated vector transitions do not support reversing prior to API level 24
android.R.attr#state_focused
android.R.attr#state_window_focused
android.R.attr#state_enabled
android.R.attr#state_checkable
android.R.attr#state_checked
android.R.attr#state_selected
android.R.attr#state_activated
android.R.attr#state_active
android.R.attr#state_single
android.R.attr#state_first
android.R.attr#state_middle
android.R.attr#state_last
android.R.attr#state_pressed
Summary
Public constructors | |
---|---|
<init>() |
Public methods | |
---|---|
open Unit |
Add a new drawable to the set of keyframes. |
open Unit |
addTransition(fromId: Int, toId: Int, @NonNull transition: T, reversible: Boolean) Adds a new transition between keyframes. |
open static AnimatedStateListDrawableCompat? |
Creates an AnimatedStateListDrawableCompat. |
open static AnimatedStateListDrawableCompat! |
createFromXmlInner(@NonNull context: Context, @NonNull resources: Resources, @NonNull parser: XmlPullParser, @NonNull attrs: AttributeSet, @Nullable theme: Theme?) Create a AnimatedStateListDrawableCompat from inside an XML document using an optional |
open Unit |
inflate(@NonNull context: Context, @NonNull resources: Resources, @NonNull parser: XmlPullParser, @NonNull attrs: AttributeSet, @Nullable theme: Theme?) Inflate this Drawable from an XML resource optionally styled by a theme. |
open Boolean | |
open Unit | |
open Drawable |
mutate() |
open Boolean |
setVisible(visible: Boolean, restart: Boolean) |
Protected methods | |
---|---|
open Boolean |
onStateChange(stateSet: IntArray!) |
Public constructors
<init>
AnimatedStateListDrawableCompat()
Public methods
addState
open fun addState(
@NonNull stateSet: IntArray,
@NonNull drawable: Drawable,
id: Int
): Unit
Add a new drawable to the set of keyframes.
Parameters | |
---|---|
stateSet |
IntArray: An array of resource IDs to associate with the keyframe |
drawable |
Drawable: The drawable to show when in the specified state, may not be null |
id |
Int: The unique identifier for the keyframe |
addTransition
open fun <T> addTransition(
fromId: Int,
toId: Int,
@NonNull transition: T,
reversible: Boolean
): Unit where T : Drawable!, T : Animatable!
Adds a new transition between keyframes.
Parameters | |
---|---|
fromId |
Int: Unique identifier of the starting keyframe |
toId |
Int: Unique identifier of the ending keyframe |
transition |
T: An Animatable drawable to use as a transition, may not be null |
reversible |
Boolean: Whether the transition can be reversed |
create
@Nullable open static fun create(
@NonNull context: Context,
@DrawableRes resId: Int,
@Nullable theme: Theme?
): AnimatedStateListDrawableCompat?
Creates an AnimatedStateListDrawableCompat.
Parameters | |
---|---|
context |
Context: context to inflate against |
resId |
Int: the resource ID for AnimatedStateListDrawable object. |
theme |
Theme?: the theme to apply, may be null. |
Return | |
---|---|
AnimatedStateListDrawableCompat? |
a new AnimatedStateListDrawableCompat or null if parsing error is found. |
createFromXmlInner
open static fun createFromXmlInner(
@NonNull context: Context,
@NonNull resources: Resources,
@NonNull parser: XmlPullParser,
@NonNull attrs: AttributeSet,
@Nullable theme: Theme?
): AnimatedStateListDrawableCompat!
Create a AnimatedStateListDrawableCompat from inside an XML document using an optional Resources.Theme
. Called on a parser positioned at a tag in an XML document, tries to create an AnimatedStateListDrawableCompat from that tag.
inflate
open fun inflate(
@NonNull context: Context,
@NonNull resources: Resources,
@NonNull parser: XmlPullParser,
@NonNull attrs: AttributeSet,
@Nullable theme: 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.
Parameters | |
---|---|
r |
Resources used to resolve attribute values |
parser |
XmlPullParser: XML parser from which to inflate this Drawable |
attrs |
AttributeSet: Base set of attribute values |
theme |
Theme?: Theme to apply, may be null |
context |
Context: context to inflate against |
resources |
Resources: Resources used to resolve attribute values |
Exceptions | |
---|---|
XmlPullParserException |
|
IOException |
isStateful
open fun i