StateListAnimator

open class StateListAnimator : Cloneable
kotlin.Any
   ↳ android.animation.StateListAnimator

Lets you define a number of Animators that will run on the attached View depending on the View's drawable state.

It can be defined in an XML file with the <selector> element. Each State Animator is defined in a nested <item> element.
Requires API level 21 (Android 5.0, Lollipop)

Summary

XML attributes
android:state_focused

android:state_window_focused

android:state_enabled

android:state_checkable

android:state_checked

android:state_selected

android:state_activated

android:state_active

android:state_single

android:state_first

android:state_middle

android:state_last

android:state_pressed

android:animation

Public constructors

Public methods
open Unit
addState(specs: IntArray!, animator: Animator!)

Associates the given animator with the provided drawable state specs so that it will be run when the View's drawable state matches the specs.

open StateListAnimator

Creates and returns a copy of this object.

open Unit

If there is an animation running for a recent state change, ends it.

XML attributes

android:state_focused

android:state_focused
State value for StateListDrawable, set when a view has input focus.

May be a boolean value, such as "true" or "false".

android:state_window_focused

android:state_window_focused
State value for StateListDrawable, set when a view's window has input focus.

May be a boolean value, such as "true" or "false".

android:state_enabled

android:state_enabled
State value for StateListDrawable, set when a view is enabled.

May be a boolean value, such as "true" or "false".

android:state_checkable

android:state_checkable
State identifier indicating that the object may display a check mark. See android.R.attr#state_checked for the identifier that indicates whether it is actually checked.

May be a boolean value, such as "true" or "false".

android:state_checked

android:state_checked
State identifier indicating that the object is currently checked. See android.R.attr#state_checkable for an additional identifier that can indicate if any object may ever display a check, regardless of whether state_checked is currently set.

May be a boolean value, such as "true" or "false".

android:state_selected

android:state_selected
State value for StateListDrawable, set when a view (or one of its parents) is currently selected.

May be a boolean value, such as "true" or "false".

android:state_activated

android:state_activated
State value for StateListDrawable, set when a view or its parent has been "activated" meaning the user has currently marked it as being of interest. This is an alternative representation of state_checked for when the state should be propagated down the view hierarchy.

May be a boolean value, such as "true" or "false".

android:state_active

android:state_active
State value for StateListDrawable, set when a view or drawable is considered "active" by its host. Actual usage may vary between views. Consult the host view documentation for details.

May be a boolean value, such as "true" or "false".

android:state_single

android:state_single
State value for StateListDrawable, set when a view or drawable is considered "single" by its host. Actual usage may vary between views. Consult the host view documentation for details.

May be a boolean value, such as "true" or "false".

android:state_first

android:state_first
State value for StateListDrawable, set when a view or drawable is in the first position in an ordered set. Actual usage may vary between views. Consult the host view documentation for details.

May be a boolean value, such as "true" or "false".

android:state_middle

android:state_middle
State value for StateListDrawable, set when a view or drawable is in the middle position in an ordered set. Actual usage may vary between views. Consult the host view documentation for details.

May be a boolean value, such as "true" or "false".

android:state_last

android:state_last
State value for StateListDrawable, set when a view or drawable is in the last position in an ordered set. Actual usage may vary between views. Consult the host view documentation for details.

May be a boolean value, such as "true" or "false".

android:state_pressed

android:state_pressed
State value for StateListDrawable, set when the user is pressing down in a view.

May be a boolean value, such as "true" or "false".

android:animation

android:animation
Animation to use on each child.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

Public constructors

<init>

StateListAnimator()

Public methods

addState

added in API level 21
open fun addState(specs: IntArray!, animator: Animator!): Unit

Associates the given animator with the provided drawable state specs so that it will be run when the View's drawable state matches the specs.
Requires API level 21 (Android 5.0, Lollipop)

Parameters
specs IntArray!: The drawable state specs to match against
animator IntArray!: The animator to run when the specs match

clone

added in API level 21
open fun clone(): StateListAnimator

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

 x.clone() != x
will be true, and that the expression:
 x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
 x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

The method clone for class Object performs a specific cloning operation. First, if the class of this object does not implement the interface Cloneable, then a CloneNotSupportedException is thrown. Note that all arrays are considered to implement the interface Cloneable and that the return type of the clone method of an array type T[] is T[] where T is any reference or primitive type. Otherwise, this method creates a new instance of the class of this object and initializes all its fields with exactly the contents of the corresponding fields of this object, as if by assignment; the contents of the fields are not themselves cloned. Thus, this method performs a "shallow copy" of this object, not a "deep copy" operation.

The class Object does not itself implement the interface Cloneable, so calling the clone method on an object whose class is Object will result in throwing an exception at run time. Requires API level 21 (Android 5.0, Lollipop)

Return
StateListAnimator: a clone of this instance.
Exceptions
CloneNotSupportedException if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

jumpToCurrentState

added in API level 21
open fun jumpToCurrentState(): Unit

If there is an animation running for a recent state change, ends it.

This causes the animation to assign the end value(s) to the View.
Requires API level 21 (Android 5.0, Lollipop)