Android APIs
public class

StateListAnimator

extends Object
java.lang.Object
   ↳ android.animation.StateListAnimator

Class Overview

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.

Summary

XML Attributes
Attribute Name Related Method Description
android:animation Animation to use on each child. 
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. 
android:state_active State value for StateListDrawable
android:state_checkable State identifier indicating that the object may display a check mark. 
android:state_checked State identifier indicating that the object is currently checked. 
android:state_enabled State value for StateListDrawable, set when a view is enabled. 
android:state_first State value for StateListDrawable
android:state_focused State value for StateListDrawable, set when a view has input focus. 
android:state_last State value for StateListDrawable
android:state_middle State value for StateListDrawable
android:state_pressed State value for StateListDrawable, set when the user is pressing down in a view. 
android:state_selected State value for StateListDrawable, set when a view (or one of its parents) is currently selected. 
android:state_single State value for StateListDrawable
android:state_window_focused State value for StateListDrawable, set when a view's window has input focus. 
Public Constructors
StateListAnimator()
Public Methods
void addState(int[] specs, 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.
void jumpToCurrentState()
If there is an animation running for a recent state change, ends it.
[Expand]
Inherited Methods
From class java.lang.Object

XML Attributes

android:animation

Animation to use on each child.

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

This corresponds to the global attribute resource symbol animation.

Related Methods

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.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_activated.

Related Methods

android:state_active

State value for StateListDrawable.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_active.

Related Methods

android:state_checkable

State identifier indicating that the object may display a check mark. See state_checked for the identifier that indicates whether it is actually checked.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_checkable.

Related Methods

android:state_checked

State identifier indicating that the object is currently checked. See 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.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_checked.

Related Methods

android:state_enabled

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

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_enabled.

Related Methods

android:state_first

State value for StateListDrawable.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_first.

Related Methods

android:state_focused

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

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_focused.

Related Methods

android:state_last

State value for StateListDrawable.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_last.

Related Methods

android:state_middle

State value for StateListDrawable.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_middle.

Related Methods

android:state_pressed

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

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_pressed.

Related Methods

android:state_selected

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

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_selected.

Related Methods

android:state_single

State value for StateListDrawable.

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_single.

Related Methods

android:state_window_focused

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

Must be a boolean value, either "true" or "false".

This may also be a reference to a resource (in the form "@[package:]type:name") or theme attribute (in the form "?[package:][type:]name") containing a value of this type.

This corresponds to the global attribute resource symbol state_window_focused.

Related Methods

Public Constructors

public StateListAnimator ()

Public Methods

public void addState (int[] specs, 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.

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

public void jumpToCurrentState ()

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.