public class AnimatedStateListDrawable extends StateListDrawable
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.
DrawableContainer.DrawableContainerState
Drawable.Callback, Drawable.ConstantState
Constructor and Description |
---|
AnimatedStateListDrawable() |
Modifier and Type | Method and Description |
---|---|
void |
addState(int[] stateSet,
Drawable drawable,
int id)
Add a new drawable to the set of keyframes.
|
<T extends Drawable & Animatable> |
addTransition(int fromId,
int toId,
T transition,
boolean reversible)
Adds a new transition between keyframes.
|
void |
applyTheme(Resources.Theme theme)
Applies the specified theme to this Drawable and its children.
|
void |
clearMutated()
Clears the mutated state, allowing this drawable to be cached and
mutated again.
|
void |
inflate(Resources r,
XmlPullParser parser,
AttributeSet attrs,
Resources.Theme theme)
Inflate this Drawable from an XML resource optionally styled by a theme.
|
boolean |
isStateful()
Indicates whether this drawable will change its appearance based on
state.
|
void |
jumpToCurrentState()
If this Drawable does transition animations between states, ask that
it immediately jump to the current state and skip any active animations.
|
Drawable |
mutate()
Make this drawable mutable.
|
protected boolean |
onStateChange(int[] stateSet)
Override this in your subclass to change appearance if you recognize the
specified state.
|
protected void |
setConstantState(DrawableContainer.DrawableContainerState state) |
boolean |
setVisible(boolean visible,
boolean restart)
Set whether this Drawable is visible.
|
addState, getStateCount, getStateDrawable, getStateDrawableIndex, getStateSet
canApplyTheme, draw, getAlpha, getChangingConfigurations, getConstantState, getCurrent, getCurrentIndex, getHotspotBounds, getIntrinsicHeight, getIntrinsicWidth, getMinimumHeight, getMinimumWidth, getOpacity, getOpticalInsets, getOutline, getPadding, invalidateDrawable, isAutoMirrored, onBoundsChange, onLayoutDirectionChanged, onLevelChange, scheduleDrawable, selectDrawable, setAlpha, setAutoMirrored, setColorFilter, setCurrentIndex, setDither, setEnterFadeDuration, setExitFadeDuration, setHotspot, setHotspotBounds, setTintList, setTintMode, unscheduleDrawable, updateDensity
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getBounds, getCallback, getColorFilter, getDirtyBounds, getLayoutDirection, getLevel, getState, getTransparentRegion, inflate, invalidateSelf, isFilterBitmap, isProjected, isVisible, obtainAttributes, parseTintMode, resolveOpacity, scheduleSelf, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setFilterBitmap, setLayoutDirection, setLevel, setState, setTint, setXfermode, unscheduleSelf
public boolean setVisible(boolean visible, boolean restart)
Drawable
setVisible
in class DrawableContainer
visible
- Set to true if visible, false if not.restart
- You can supply true here to force the drawable to behave
as if it has just become visible, even if it had last
been set visible. Used for example to force animations
to restart.public void addState(int[] stateSet, Drawable drawable, int id)
stateSet
- An array of resource IDs to associate with the keyframedrawable
- The drawable to show when in the specified state, may not be nullid
- The unique identifier for the keyframepublic <T extends Drawable & Animatable> void addTransition(int fromId, int toId, T transition, boolean reversible)
fromId
- Unique identifier of the starting keyframetoId
- Unique identifier of the ending keyframetransition
- An Animatable
drawable to use as a transition, may not be nullreversible
- Whether the transition can be reversedpublic boolean isStateful()
Drawable
isStateful
in class StateListDrawable
Drawable.setState(int[])
protected boolean onStateChange(int[] stateSet)
Drawable
onStateChange
in class StateListDrawable
public void jumpToCurrentState()
Drawable
jumpToCurrentState
in class DrawableContainer
public void inflate(Resources r, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme) throws XmlPullParserException, IOException
Drawable
inflate
in class StateListDrawable
r
- Resources used to resolve attribute valuesparser
- XML parser from which to inflate this Drawableattrs
- Base set of attribute valuestheme
- Theme to apply, may be nullXmlPullParserException
IOException
public void applyTheme(Resources.Theme theme)
Drawable
applyTheme
in class StateListDrawable
theme
- the theme to applypublic Drawable mutate()
Drawable
mutate
in class StateListDrawable
Drawable.ConstantState
,
Drawable.getConstantState()
public void clearMutated()
Drawable
This is hidden because only framework drawables can be cached, so custom drawables don't need to support constant state, mutate(), or clearMutated().
clearMutated
in class StateListDrawable
protected void setConstantState(DrawableContainer.DrawableContainerState state)
setConstantState
in class StateListDrawable