android.graphics.drawable
Class TransitionDrawable
java.lang.Object
android.graphics.drawable.Drawable
android.graphics.drawable.LayerDrawable
android.graphics.drawable.TransitionDrawable
- All Implemented Interfaces:
- Drawable.Callback
public class TransitionDrawable
- extends LayerDrawable
- implements Drawable.Callback
Transition drawables are an extension of LayerDrawables and are intended to cross fade between
the first and second layers. To start the transition, call startTransition(int). To
display just the first layer, call resetTransition()
| Methods inherited from class android.graphics.drawable.LayerDrawable |
findDrawableByLayerId, getChangingConfigurations, getConstantState, getDrawable, getId, getIntrinsicHeight, getIntrinsicWidth, getNumberOfLayers, getOpacity, getPadding, inflate, invalidateDrawable, isStateful, onBoundsChange, onLevelChange, onStateChange, scheduleDrawable, setAlpha, setColorFilter, setDither, setDrawableByLayerId, setId, setLayerInset, setVisible, unscheduleDrawable |
| Methods inherited from class android.graphics.drawable.Drawable |
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromStream, createFromXml, createFromXmlInner, getBounds, getCurrent, getLevel, getMinimumHeight, getMinimumWidth, getState, getTransparentRegion, inflateWithAttributes, invalidateSelf, isVisible, resolveOpacity, scheduleSelf, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setFilterBitmap, setLevel, setState, unscheduleSelf |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TransitionDrawable
TransitionDrawable()
createConstantState
LayerDrawable.LayerState createConstantState(LayerDrawable.LayerState state)
- Overrides:
createConstantState in class LayerDrawable
startTransition
public void startTransition(int durationMillis)
- Begin the second layer on top of the first layer.
- Parameters:
durationMillis - The length of the transition in milliseconds
resetTransition
public void resetTransition()
- Show only the first layer.
reverseTransition
public void reverseTransition(int duration)
- Reverses the transition, picking up where the transition currently is.
If the transition is not currently running, this will start the transition
with the specified duration. If the transition is already running, the last
known duration will be used.
- Parameters:
duration - The duration to use if no transition is running.
draw
public void draw(Canvas canvas)
- Description copied from class:
Drawable
- Draw in its bounds (set via setBounds) respecting optional effects such
as alpha (set via setAlpha) and color filter (set via setColorFilter).
- Overrides:
draw in class LayerDrawable
- Parameters:
canvas - The canvas to draw into
setCrossFadeEnabled
public void setCrossFadeEnabled(boolean enabled)
- Enables or disables the cross fade of the drawables. When cross fade
is disabled, the first drawable is always drawn opaque. With cross
fade enabled, the first drawable is drawn with the opposite alpha of
the second drawable.
- Parameters:
enabled - True to enable cross fading, false otherwise.
isCrossFadeEnabled
public boolean isCrossFadeEnabled()
- Indicates whether the cross fade is enabled for this transition.
- Returns:
- True if cross fading is enabled, false otherwise.
Please submit a feedback, bug or feature