public class TransitionDrawable extends LayerDrawable implements Drawable.Callback
startTransition(int)
. To
display just the first layer, call resetTransition()
.
It can be defined in an XML file with the <transition>
element.
Each Drawable in the transition is defined in a nested <item>
. For more
information, see the guide to Drawable Resources.
Drawable.Callback, Drawable.ConstantState
INSET_UNDEFINED, PADDING_MODE_NEST, PADDING_MODE_STACK
Constructor and Description |
---|
TransitionDrawable(Drawable[] layers)
Create a new transition drawable with the specified list of layers.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(Canvas canvas)
Draw in its bounds (set via setBounds) respecting optional effects such
as alpha (set via setAlpha) and color filter (set via setColorFilter).
|
boolean |
isCrossFadeEnabled()
Indicates whether the cross fade is enabled for this transition.
|
void |
resetTransition()
Show only the first layer.
|
void |
reverseTransition(int duration)
Reverses the transition, picking up where the transition currently is.
|
void |
setCrossFadeEnabled(boolean enabled)
Enables or disables the cross fade of the drawables.
|
void |
startTransition(int durationMillis)
Begin the second layer on top of the first layer.
|
addLayer, applyTheme, canApplyTheme, clearMutated, findDrawableByLayerId, findIndexByLayerId, getAlpha, getBottomPadding, getChangingConfigurations, getConstantState, getDrawable, getEndPadding, getHotspotBounds, getId, getIntrinsicHeight, getIntrinsicWidth, getLayerGravity, getLayerHeight, getLayerInsetBottom, getLayerInsetEnd, getLayerInsetLeft, getLayerInsetRight, getLayerInsetStart, getLayerInsetTop, getLayerWidth, getLeftPadding, getNumberOfLayers, getOpacity, getOutline, getPadding, getPaddingMode, getRightPadding, getStartPadding, getTopPadding, inflate, invalidateDrawable, isAutoMirrored, isProjected, isStateful, jumpToCurrentState, mutate, onBoundsChange, onLayoutDirectionChanged, onLevelChange, onStateChange, scheduleDrawable, setAlpha, setAutoMirrored, setColorFilter, setDither, setDrawable, setDrawableByLayerId, setHotspot, setHotspotBounds, setId, setLayerGravity, setLayerHeight, setLayerInset, setLayerInsetBottom, setLayerInsetEnd, setLayerInsetLeft, setLayerInsetRelative, setLayerInsetRight, setLayerInsetStart, setLayerInsetTop, setLayerSize, setLayerWidth, setOpacity, setPadding, setPaddingMode, setPaddingRelative, setTintList, setTintMode, setVisible, unscheduleDrawable
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getBounds, getCallback, getColorFilter, getCurrent, getDirtyBounds, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getOpticalInsets, getState, getTransparentRegion, inflate, invalidateSelf, isFilterBitmap, isVisible, obtainAttributes, parseTintMode, resolveOpacity, scheduleSelf, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setFilterBitmap, setLayoutDirection, setLevel, setState, setTint, setXfermode, unscheduleSelf
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
invalidateDrawable, scheduleDrawable, unscheduleDrawable
public TransitionDrawable(Drawable[] layers)
public void startTransition(int durationMillis)
durationMillis
- The length of the transition in millisecondspublic void resetTransition()
public void reverseTransition(int duration)
duration
- The duration to use if no transition is running.public void draw(Canvas canvas)
Drawable
draw
in class LayerDrawable
canvas
- The canvas to draw intopublic void setCrossFadeEnabled(boolean enabled)
enabled
- True to enable cross fading, false otherwise.public boolean isCrossFadeEnabled()