public class DrawableCrossFadeTransition extends Object implements Transition<Drawable>
Transition for Drawables that uses an
TransitionDrawable to transition from an existing drawable
already visible on the target to a new drawable. If no existing drawable exists, this class can
instead fall back to a default animation that doesn't rely on TransitionDrawable.Transition.ViewAdapter| Constructor and Description |
|---|
DrawableCrossFadeTransition(Transition<Drawable> defaultAnimation,
int duration,
boolean isCrossFadeEnabled)
Constructor that takes a default animation and a duration in milliseconds that the cross fade
animation should last.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
transition(Drawable current,
Transition.ViewAdapter adapter)
Animates from the previous drawable to the current drawable in one of two ways.
|
public DrawableCrossFadeTransition(Transition<Drawable> defaultAnimation, int duration, boolean isCrossFadeEnabled)
defaultAnimation - The Transition to use if there is no previous
Drawable (either a placeholder or previous resource) to
transition from.duration - The duration that the cross fade animation should run if there is something to
cross fade from when a new Drawable is put.isCrossFadeEnabled - If true, animates the previous resource's alpha to 0 while
animating the new resource's alpha to 100. Otherwise, only animates
the new resource's alpha to 100 while leaving the previous resource's
alpha at 100. See
TransitionDrawable.setCrossFadeEnabled(boolean).public boolean transition(Drawable current, Transition.ViewAdapter adapter)
transition in interface Transition<Drawable>current - The new resource that will be displayed in the view.adapter - The Transition.ViewAdapter wrapping a view that can at least return an
View from Transition.ViewAdapter.getView().