AnimatedStateListDrawableCompat
public
class
AnimatedStateListDrawableCompat
extends Drawable
implements
Drawable.Callback
A Drawable
providing animated transitions between states.
A port of 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
R.attr.state_focused
R.attr.state_window_focused
R.attr.state_enabled
R.attr.state_checkable
R.attr.state_checked
R.attr.state_selected
R.attr.state_activated
R.attr.state_active
R.attr.state_single
R.attr.state_first
R.attr.state_middle
R.attr.state_last
R.attr.state_pressed
Summary
Public methods |
void
|
addState(int[] stateSet, Drawable drawable, int id)
Add a new drawable to the set of keyframes.
|
void
|
addState(int[] stateSet, Drawable drawable)
Add a new image/string ID to the set of images.
|
<T extends Drawable & Animatable>
void
|
addTransition(int fromId, int toId, T transition, boolean reversible)
Adds a new transition between keyframes.
|
void
|
applyTheme(Resources.Theme theme)
|
boolean
|
canApplyTheme()
|
static
AnimatedStateListDrawableCompat
|
create(Context context, int resId, Resources.Theme theme)
Creates an AnimatedStateListDrawableCompat.
|
static
AnimatedStateListDrawableCompat
|
createFromXmlInner(Context context, Resources resources, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme)
Create a AnimatedStateListDrawableCompat from inside an XML document using an optional
Resources.Theme .
|
void
|
draw(Canvas canvas)
|
int
|
getAlpha()
|
int
|
getChangingConfigurations()
|
final
Drawable.ConstantState
|
getConstantState()
|
Drawable
|
getCurrent()
|
void
|
getHotspotBounds(Rect outRect)
|
int
|
getIntrinsicHeight()
|
int
|
getIntrinsicWidth()
|
int
|
getMinimumHeight()
|
int
|
getMinimumWidth()
|
int
|
getOpacity()
|
void
|
getOutline(Outline outline)
|
boolean
|
getPadding(Rect padding)
|
void
|
inflate(Context context, Resources resources, XmlPullParser parser, AttributeSet attrs, Resources.Theme theme)
Inflate this Drawable from an XML resource optionally styled by a theme.
|
void
|
invalidateDrawable(Drawable who)
|
boolean
|
isAutoMirrored()
|
boolean
|
isStateful()
|
void
|
jumpToCurrentState()
|
Drawable
|
mutate()
|
boolean
|
onLayoutDirectionChanged(int layoutDirection)
|
void
|
scheduleDrawable(Drawable who, Runnable what, long when)
|
void
|
setAlpha(int alpha)
|
void
|
setAutoMirrored(boolean mirrored)
|
void
|
setColorFilter(ColorFilter colorFilter)
|
void
|
setDither(boolean dither)
|
void
|
setEnterFadeDuration(int ms)
Change the global fade duration when a new drawable is entering
the scene.
|
void
|
setExitFadeDuration(int ms)
Change the global fade duration when a new drawable is leaving
the scene.
|
void
|
setHotspot(float x, float y)
|
void
|
setHotspotBounds(int left, int top, int right, int bottom)
|
void
|
setTintList(ColorStateList tint)
|
void
|
setTintMode(PorterDuff.Mode tintMode)
|
boolean
|
setVisible(boolean visible, boolean restart)
|
void
|
unscheduleDrawable(Drawable who, Runnable what)
|
Inherited methods |
From class
android.graphics.drawable.Drawable
void
|
applyTheme(Resources.Theme arg0)
|
boolean
|
canApplyTheme()
|
void
|
clearColorFilter()
|
final
Rect
|
copyBounds()
|
final
void
|
copyBounds(Rect arg0)
|
static
Drawable
|
createFromPath(String arg0)
|
static
Drawable
|
createFromResourceStream(Resources arg0, TypedValue arg1, InputStream arg2, String arg3, BitmapFactory.Options arg4)
|
static
Drawable
|
createFromResourceStream(Resources arg0, TypedValue arg1, InputStream arg2, String arg3)
|
static
Drawable
|
createFromStream(InputStream arg0, String arg1)
|
static
Drawable
|
createFromXml(Resources arg0, XmlPullParser arg1)
|
static
Drawable
|
createFromXml(Resources arg0, XmlPullParser arg1, Resources.Theme arg2)
|
static
Drawable
|
createFromXmlInner(Resources arg0, XmlPullParser arg1, AttributeSet arg2, Resources.Theme arg3)
|
static
Drawable
|
createFromXmlInner(Resources arg0, XmlPullParser arg1, AttributeSet arg2)
|
abstract
void
|
draw(Canvas arg0)
|
int
|
getAlpha()
|
final
Rect
|
getBounds()
|
Drawable.Callback
|
getCallback()
|
int
|
getChangingConfigurations()
|
ColorFilter
|
getColorFilter()
|
Drawable.ConstantState
|
getConstantState()
|
Drawable
|
getCurrent()
|
Rect
|
getDirtyBounds()
|
void
|
getHotspotBounds(Rect arg0)
|
int
|
getIntrinsicHeight()
|
int
|
getIntrinsicWidth()
|
int
|
getLayoutDirection()
|
final
int
|
getLevel()
|
int
|
getMinimumHeight()
|
int
|
getMinimumWidth()
|
abstract
int
|
getOpacity()
|
Insets
|
getOpticalInsets()
|
void
|
getOutline(Outline arg0)
|
boolean
|
getPadding(Rect arg0)
|
int[]
|
getState()
|
Region
|
getTransparentRegion()
|
void
|
inflate(Resources arg0, XmlPullParser arg1, AttributeSet arg2, Resources.Theme arg3)
|
void
|
inflate(Resources arg0, XmlPullParser arg1, AttributeSet arg2)
|
void
|
invalidateSelf()
|
boolean
|
isAutoMirrored()
|
boolean
|
isFilterBitmap()
|
boolean
|
isProjected()
|
boolean
|
isStateful()
|
final
boolean
|
isVisible()
|
void
|
jumpToCurrentState()
|
Drawable
|
mutate()
|
void
|
onBoundsChange(Rect arg0)
|
boolean
|
onLayoutDirectionChanged(int arg0)
|
boolean
|
onLevelChange(int arg0)
|
boolean
|
onStateChange(int[] arg0)
|
static
int
|
resolveOpacity(int arg0, int arg1)
|
void
|
scheduleSelf(Runnable arg0, long arg1)
|
abstract
void
|
setAlpha(int arg0)
|
void
|
setAutoMirrored(boolean arg0)
|
void
|
setBounds(int arg0, int arg1, int arg2, int arg3)
|
void
|
setBounds(Rect arg0)
|
final
void
|
setCallback(Drawable.Callback arg0)
|
void
|
setChangingConfigurations(int arg0)
|
void
|
setColorFilter(int arg0, PorterDuff.Mode arg1)
|
abstract
void
|
setColorFilter(ColorFilter arg0)
|
void
|
setDither(boolean arg0)
|
void
|
setFilterBitmap(boolean arg0)
|
void
|
setHotspot(float arg0, float arg1)
|
void
|
setHotspotBounds(int arg0, int arg1, int arg2, int arg3)
|
final
boolean
|
setLayoutDirection(int arg0)
|
final
boolean
|
setLevel(int arg0)
|
boolean
|
setState(int[] arg0)
|
void
|
setTint(int arg0)
|
void
|
setTintBlendMode(BlendMode arg0)
|
void
|
setTintList(ColorStateList arg0)
|
void
|
setTintMode(PorterDuff.Mode arg0)
|
boolean
|
setVisible(boolean arg0, boolean arg1)
|
void
|
unscheduleSelf(Runnable arg0)
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
|
Public constructors
AnimatedStateListDrawableCompat
public AnimatedStateListDrawableCompat ()
Public methods
addState
public void addState (int[] stateSet,
Drawable drawable,
int id)
Add a new drawable to the set of keyframes.
Parameters |
stateSet |
int : 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
|
addState
public void addState (int[] stateSet,
Drawable drawable)
Add a new image/string ID to the set of images.
Parameters |
stateSet |
int : - An array of resource Ids to associate with the image.
Switch to this image by calling setState(). |
drawable |
Drawable : -The image to show.
|
addTransition
public void addTransition (int fromId,
int toId,
T transition,
boolean reversible)
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
|
applyTheme
public void applyTheme (Resources.Theme theme)
Parameters |
theme |
Resources.Theme |
canApplyTheme
public boolean canApplyTheme ()
create
public static AnimatedStateListDrawableCompat create (Context context,
int resId,
Resources.Theme theme)
Creates an AnimatedStateListDrawableCompat.
Parameters |
context |
Context : context to inflate against |
resId |
int : the resource ID for AnimatedStateListDrawable object. |
theme |
Resources.Theme : the theme to apply, may be null. |
createFromXmlInner
public static AnimatedStateListDrawableCompat createFromXmlInner (Context context,
Resources resources,
XmlPullParser parser,
AttributeSet attrs,
Resources.Theme theme)
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.
Parameters |
context |
Context |
resources |
Resources |
parser |
XmlPullParser |
attrs |
AttributeSet |
theme |
Resources.Theme |
Throws |
IOException |
|
XmlPullParserException |
|
draw
public void draw (Canvas canvas)
getAlpha
public int getAlpha ()
getChangingConfigurations
public int getChangingConfigurations ()
getCurrent
public Drawable getCurrent ()
getHotspotBounds
public void getHotspotBounds (Rect outRect)
getIntrinsicHeight
public int getIntrinsicHeight ()
getIntrinsicWidth
public int getIntrinsicWidth ()
getMinimumHeight
public int getMinimumHeight ()
getMinimumWidth
public int getMinimumWidth ()
getOpacity
public int getOpacity ()
getOutline
public void getOutline (Outline outline)
Parameters |
outline |
Outline |
getPadding
public boolean getPadding (Rect padding)
inflate
public void inflate (Context context,
Resources resources,
XmlPullParser parser,
AttributeSet attrs,
Resources.Theme theme)
Inflate this Drawable from an XML resource optionally styled by a theme.
This can't be called more than once for each Drawable.
Parameters |
context |
Context : context to inflate against |
resources |
Resources : Resources used to resolve attribute values |
parser |
XmlPullParser : XML parser from which to inflate this Drawable |
attrs |
AttributeSet : Base set of attribute values |
theme |
Resources.Theme : Theme to apply, may be null |
Throws |
|
XmlPullParserException |
IOException |
|
XmlPullParserException |
|
invalidateDrawable
public void invalidateDrawable (Drawable who)
isAutoMirrored
public boolean isAutoMirrored ()
isStateful
public boolean isStateful ()
jumpToCurrentState
public void jumpToCurrentState ()
onLayoutDirectionChanged
public boolean onLayoutDirectionChanged (int layoutDirection)
Parameters |
layoutDirection |
int |
scheduleDrawable
public void scheduleDrawable (Drawable who,
Runnable what,
long when)
Parameters |
who |
Drawable |
what |
Runnable |
when |
long |
setAlpha
public void setAlpha (int alpha)
setAutoMirrored
public void setAutoMirrored (boolean mirrored)
Parameters |
mirrored |
boolean |
setColorFilter
public void setColorFilter (ColorFilter colorFilter)
Parameters |
colorFilter |
ColorFilter |
setDither
public void setDither (boolean dither)
Parameters |
dither |
boolean |
setEnterFadeDuration
public void setEnterFadeDuration (int ms)
Change the global fade duration when a new drawable is entering
the scene.
Parameters |
ms |
int : The amount of time to fade in milliseconds.
|
setExitFadeDuration
public void setExitFadeDuration (int ms)
Change the global fade duration when a new drawable is leaving
the scene.
Parameters |
ms |
int : The amount of time to fade in milliseconds.
|
setHotspot
public void setHotspot (float x,
float y)
Parameters |
x |
float |
y |
float |
setHotspotBounds
public void setHotspotBounds (int left,
int top,
int right,
int bottom)
Parameters |
left |
int |
top |
int |
right |
int |
bottom |
int |
setTintList
public void setTintList (ColorStateList tint)
Parameters |
tint |
ColorStateList |
setTintMode
public void setTintMode (PorterDuff.Mode tintMode)
Parameters |
tintMode |
PorterDuff.Mode |
setVisible
public boolean setVisible (boolean visible,
boolean restart)
Parameters |
visible |
boolean |
restart |
boolean |
unscheduleDrawable
public void unscheduleDrawable (Drawable who,
Runnable what)
Parameters |
who |
Drawable |
what |
Runnable |
Protected methods
onBoundsChange
protected void onBoundsChange (Rect bounds)
onLevelChange
protected boolean onLevelChange (int level)
onStateChange
protected boolean onStateChange (int[] stateSet)