public class Translate extends Visibility
Visibility transition implementation that tracks changes to the visibility of target
views in the start and end scenes and translates/moves views in the scene. Visibility is
determined by both the View.setVisibility(int) state of the view as well as whether it
is parented in the current view hierarchy. Disappearing Views are limited as described in
Visibility.onDisappear(android.view.ViewGroup, TransitionValues, int, TransitionValues, int).
This transition differs from Slide transition in a way that it
allows to translate a concrete view by a desired delta in both X and Y axes. The delta value by
which should be the view translated/moved may be specified either as fixed/absolute value or as
relative value to the the target view or to the scene where is the view presented. Delta values
for translate animation may be specified via setTranslationXDelta(float) and
setTranslationYDelta(float) and theirs "relativity" via setTranslationXRelativity(int)
and setTranslationYRelativity(int) where the specified relativity types will indicate
how the delta values should be treated.
Translate transition can be described in a resource file by using the transition tag with
class attribute set to universum.studios.android.transition.Translate, along with
Xml attributes referenced below.
Translate Attributes| Modifier and Type | Class and Description |
|---|---|
static interface |
Translate.DeltaResolver
DeltaResolver specifies an interface that may be used to resolve delta value for translate
animation along both X and Y axes.
|
static class |
Translate.Description
Describes a translation delta value specified via one of
uiTranslationXDelta,
uiTranslationYDelta attributes. |
static interface |
Translate.TranslateMode
Defines an annotation for determining set of allowed modes for Translate transition.
|
Transition.EpicenterCallback, Transition.TransitionListener| Modifier and Type | Field and Description |
|---|---|
static Translate.DeltaResolver |
DELTA_RESOLVER
Default implementation of
Translate.DeltaResolver used to resolve translation delta values
for Visibility.onAppear(ViewGroup, TransitionValues, int, TransitionValues, int) and
Visibility.onDisappear(ViewGroup, TransitionValues, int, TransitionValues, int) methods. |
static TimeInterpolator |
INTERPOLATOR
Default interpolator attached to
Animator created via createAnimator(Transition, View, TransitionValues, int, int, float, float, float, float). |
MODE_IN, MODE_OUTMATCH_ID, MATCH_INSTANCE, MATCH_ITEM_ID, MATCH_NAME| Constructor and Description |
|---|
Translate()
|
Translate(Context context,
AttributeSet attrs)
Creates a new instance of Translate transition with animation property values set from the
specified attrs.
|
Translate(int mode)
Creates a new instance of Translate transition with the specified mode.
|
| Modifier and Type | Method and Description |
|---|---|
void |
captureEndValues(TransitionValues transitionValues) |
void |
captureStartValues(TransitionValues transitionValues) |
static Animator |
createAnimator(Transition transition,
View view,
TransitionValues transitionValues,
int viewX,
int viewY,
float startX,
float startY,
float endX,
float endY)
Creates a new instance of Animator that animates both, translation X and translation Y, properties
of the specified view with respect to its current translation values.
|
float |
getTranslationXDelta()
Returns the delta by which should be the target view translated/moved in the root scene along
X axis.
|
int |
getTranslationXRelativity()
Returns the relativity type describing value returned by
getTranslationXDelta(). |
float |
getTranslationYDelta()
Returns the delta by which should be the target view translated/moved in the root scene along
Y axis.
|
int |
getTranslationYRelativity()
Returns the relativity type describing value returned by
getTranslationYDelta(). |
Animator |
onAppear(ViewGroup sceneRoot,
View view,
TransitionValues startValues,
TransitionValues endValues) |
Animator |
onDisappear(ViewGroup sceneRoot,
View view,
TransitionValues startValues,
TransitionValues endValues) |
void |
setTranslationXDelta(float xDelta)
Sets a delta value by which should be the target view translated/moved in or out, absolutely
or relatively, in the scene along X axis.
|
void |
setTranslationXRelativity(int xRelativity)
Sets a relativity type that describes how should be treated delta value for translation along
X axis specified via
setTranslationXDelta(float). |
void |
setTranslationYDelta(float yDelta)
Sets a delta value by which should be the target view translated/moved in or out, absolutely
or relatively, in the scene along Y axis.
|
void |
setTranslationYRelativity(int yRelativity)
Sets a relativity type that describes how should be treated delta value for translation along
Y axis specified via
setTranslationYDelta(float). |
createAnimator, getMode, getTransitionProperties, isTransitionRequired, isVisible, onAppear, onDisappear, setModeaddListener, addTarget, addTarget, addTarget, addTarget, canRemoveViews, clone, excludeChildren, excludeChildren, excludeChildren, excludeTarget, excludeTarget, excludeTarget, excludeTarget, getDuration, getEpicenter, getEpicenterCallback, getInterpolator, getName, getPathMotion, getPropagation, getStartDelay, getTargetIds, getTargetNames, getTargets, getTargetTypes, getTransitionValues, removeListener, removeTarget, removeTarget, removeTarget, removeTarget, setDuration, setEpicenterCallback, setInterpolator, setMatchOrder, setPathMotion, setPropagation, setStartDelay, toStringpublic static final TimeInterpolator INTERPOLATOR
Animator created via createAnimator(Transition, View, TransitionValues, int, int, float, float, float, float).public static final Translate.DeltaResolver DELTA_RESOLVER
Translate.DeltaResolver used to resolve translation delta values
for Visibility.onAppear(ViewGroup, TransitionValues, int, TransitionValues, int) and
Visibility.onDisappear(ViewGroup, TransitionValues, int, TransitionValues, int) methods.public Translate()
public Translate(int mode)
mode - One of Visibility.MODE_IN or Visibility.MODE_OUT or theirs combination.public Translate(@NonNull Context context, @Nullable AttributeSet attrs)
context - Context used to obtain values from the specified attrs.attrs - Set of attributes from which to obtain animation property values for the scale
animation.@Nullable public static Animator createAnimator(@NonNull Transition transition, @NonNull View view, @NonNull TransitionValues transitionValues, int viewX, int viewY, float startX, float startY, float endX, float endY)
The created animator also properly handles cases when the translate animation is interrupted, paused or canceled, and possibly resumed later.
The returned animator will also have the default INTERPOLATOR attached.
transition - The transition that was requested to animate the given view.view - The view for which to create the requested animator.transitionValues - Either start or end transition values containing view that is
currently in the view hierarchy.viewX - Last known X position of the view on the screen captured by the transition.viewY - Last known Y position of the view on the screen captured by the transition.startX - Translation from which to start the animation along X axis.startY - Translation from which to start the animation along Y axis.endX - Translation at which should the animation end along X axis.endY - Translation at which should the animation end along Y axis.null if the start and end translation values are
the same or the target view is already detached from window.public void setTranslationXDelta(float xDelta)
Relativity of this value may be changed via setTranslationXRelativity(int).
Default value: 0
xDelta - The desired delta. If the delta will represent a relative fraction value, the
specified value should be from the range [0.0, 1.0].ui:uiTranslationXDelta,
getTranslationXDelta(),
getTranslationXRelativity()public float getTranslationXDelta()
setTranslationXDelta(float)public void setTranslationYDelta(float yDelta)
Relativity of this value may be changed via setTranslationYRelativity(int).
Default value: 0
yDelta - The desired delta. If the delta will represent a relative fraction value, the
specified value should be from the range [0.0, 1.0].ui:uiTranslationYDelta,
getTranslationYDelta(),
getTranslationYRelativity()public float getTranslationYDelta()
setTranslationYDelta(float)public void setTranslationXRelativity(int xRelativity)
setTranslationXDelta(float). See Translate.Description for more
information about supported relativity types and also how to choose a desired one.
Default value: Translate.Description.NONE
xRelativity - The desired relativity type. One of types defined by
@ValueRelativity annotation.ui:uiTranslationXDelta,
getTranslationXRelativity()public int getTranslationXRelativity()
getTranslationXDelta().setTranslationXRelativity(int)public void setTranslationYRelativity(int yRelativity)
setTranslationYDelta(float). See Translate.Description for more
information about supported relativity types and also how to choose a desired one.
Default value: Translate.Description.NONE
yRelativity - The desired relativity type. One of types defined by
@ValueRelativity annotation.ui:uiTranslationYDelta,
getTranslationYRelativity()public int getTranslationYRelativity()
getTranslationYDelta().setTranslationYRelativity(int)public void captureStartValues(@NonNull TransitionValues transitionValues)
captureStartValues in class Visibilitypublic void captureEndValues(@NonNull TransitionValues transitionValues)
captureEndValues in class Visibility@Nullable public Animator onAppear(@NonNull ViewGroup sceneRoot, @NonNull View view, @Nullable TransitionValues startValues, @Nullable TransitionValues endValues)
onAppear in class Visibility@Nullable public Animator onDisappear(@NonNull ViewGroup sceneRoot, @NonNull View view, @Nullable TransitionValues startValues, @Nullable TransitionValues endValues)
onDisappear in class Visibility