public class

MotionScene.Transition

extends java.lang.Object

 java.lang.Object

↳androidx.constraintlayout.motion.widget.MotionScene.Transition

Overview

Transition defines the interaction from one state to another. With out a Transition object Transition between two stats involves strictly linear interpolation

Summary

Fields
public static final intAUTO_ANIMATE_TO_END

public static final intAUTO_ANIMATE_TO_START

public static final intAUTO_JUMP_TO_END

public static final intAUTO_JUMP_TO_START

public static final intAUTO_NONE

public static final intINTERPOLATE_ANTICIPATE

public static final intINTERPOLATE_BOUNCE

public static final intINTERPOLATE_EASE_IN

public static final intINTERPOLATE_EASE_IN_OUT

public static final intINTERPOLATE_EASE_OUT

public static final intINTERPOLATE_LINEAR

public static final intINTERPOLATE_OVERSHOOT

public static final intINTERPOLATE_REFERENCE_ID

public static final intINTERPOLATE_SPLINE_STRING

Constructors
publicTransition(int id, MotionScene motionScene, int constraintSetStartId, int constraintSetEndId)

Create a transition

Methods
public voidaddKeyFrame(KeyFrames keyFrames)

add a keyframe to this motion scene

public voidaddOnClick(Context context, XmlPullParser parser)

Add on Click support using the xml parser

public voidaddOnClick(int id, int action)

Add the onclick to this view

public java.lang.StringdebugString(Context context)

Print a debug string indicating the starting and ending state of the transition

public intgetAutoTransition()

return the autoTransitionType.

public intgetDuration()

gets the default transition duration

public intgetEndConstraintSetId()

Get the id of the constraint set to go to

public intgetId()

Transitions can be given and ID.

public java.util.List<KeyFrames>getKeyFrameList()

public intgetLayoutDuringTransition()

get the mode of layout during transition

public java.util.List<MotionScene.Transition.TransitionOnClick>getOnClickList()

Get the onClick handlers.

public intgetPathMotionArc()

gets the pathMotionArc for the all motions in this transition.

public floatgetStagger()

Gets the stagger value.

public intgetStartConstraintSetId()

Gets the id of the starting constraint set

public androidx.constraintlayout.motion.widget.TouchResponsegetTouchResponse()

Get the Touch response manager

public booleanisEnabled()

Returns true if this Transition can be auto considered for transition Default is enabled

public booleanisTransitionFlag(int flag)

is the transition flag set

public voidremoveOnClick(int id)

Remove the onclick added to this view

public voidsetAutoTransition(int type)

sets the autoTransitionType On reaching a state auto transitions may be run based on one of AUTO_NONE, AUTO_JUMP_TO_START, AUTO_JUMP_TO_END, AUTO_ANIMATE_TO_START, AUTO_ANIMATE_TO_END

public voidsetDuration(int duration)

sets the duration of the transition if set to < 8 it will be set to 8

public voidsetEnabled(boolean enable)

enable or disable the Transition.

public voidsetInterpolatorInfo(int interpolator, java.lang.String interpolatorString, int interpolatorID)

Sets the interpolation used for this transition.

public voidsetLayoutDuringTransition(int mode)

set the mode of layout during transition

public voidsetOnSwipe(OnSwipe onSwipe)

Set the onSwipe for this Transition

public voidsetOnTouchUp(int touchUpMode)

Set the on touch up mode

public voidsetPathMotionArc(int arcMode)

Sets the pathMotionArc for the all motions in this transition.

public voidsetStagger(float stagger)

Sets the stagger value.

public voidsetTransitionFlag(int flag)

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final int AUTO_NONE

public static final int AUTO_JUMP_TO_START

public static final int AUTO_JUMP_TO_END

public static final int AUTO_ANIMATE_TO_START

public static final int AUTO_ANIMATE_TO_END

public static final int INTERPOLATE_REFERENCE_ID

public static final int INTERPOLATE_SPLINE_STRING

public static final int INTERPOLATE_EASE_IN_OUT

public static final int INTERPOLATE_EASE_IN

public static final int INTERPOLATE_EASE_OUT

public static final int INTERPOLATE_LINEAR

public static final int INTERPOLATE_BOUNCE

public static final int INTERPOLATE_OVERSHOOT

public static final int INTERPOLATE_ANTICIPATE

Constructors

public Transition(int id, MotionScene motionScene, int constraintSetStartId, int constraintSetEndId)

Create a transition

Parameters:

id: a unique id to represent the transition.
motionScene: the motion scene that the transition will be added to.
constraintSetStartId: id of the ConstraintSet to be used for the start of transition
constraintSetEndId: id of the ConstraintSet to be used for the end of transition

Methods

public void setOnSwipe(OnSwipe onSwipe)

Set the onSwipe for this Transition

Parameters:

onSwipe:

public void addOnClick(int id, int action)

Add the onclick to this view

Parameters:

id:
action:

public void removeOnClick(int id)

Remove the onclick added to this view

Parameters:

id:

public int getLayoutDuringTransition()

get the mode of layout during transition

Returns:

public void setLayoutDuringTransition(int mode)

set the mode of layout during transition

Parameters:

mode:

public void addOnClick(Context context, XmlPullParser parser)

Add on Click support using the xml parser

Parameters:

context:
parser:

public void setAutoTransition(int type)

sets the autoTransitionType On reaching a state auto transitions may be run based on one of AUTO_NONE, AUTO_JUMP_TO_START, AUTO_JUMP_TO_END, AUTO_ANIMATE_TO_START, AUTO_ANIMATE_TO_END

Parameters:

type:

public int getAutoTransition()

return the autoTransitionType. one of AUTO_NONE, AUTO_JUMP_TO_START, AUTO_JUMP_TO_END, AUTO_ANIMATE_TO_START, AUTO_ANIMATE_TO_END

Returns:

0=NONE, 1=JUMP_TO_START, 2=JUMP_TO_END, 3=ANIMATE_TO_START, 4=ANIMATE_TO_END

public int getId()

Transitions can be given and ID. If unset it returns UNSET (-1)

Returns:

The Id of the Transition set in the MotionScene File or UNSET (-1)

public int getEndConstraintSetId()

Get the id of the constraint set to go to

Returns:

public int getStartConstraintSetId()

Gets the id of the starting constraint set

Returns:

public void setDuration(int duration)

sets the duration of the transition if set to < 8 it will be set to 8

Parameters:

duration: in milliseconds (min is 8)

public int getDuration()

gets the default transition duration

Returns:

duration int milliseconds

public float getStagger()

Gets the stagger value.

Returns:

public java.util.List<KeyFrames> getKeyFrameList()

public void addKeyFrame(KeyFrames keyFrames)

add a keyframe to this motion scene

Parameters:

keyFrames:

public java.util.List<MotionScene.Transition.TransitionOnClick> getOnClickList()

Get the onClick handlers.

Returns:

list of on click handler

public androidx.constraintlayout.motion.widget.TouchResponse getTouchResponse()

Get the Touch response manager

Returns:

public void setStagger(float stagger)

Sets the stagger value. A Stagger value of zero means no stagger. A Stagger value of 1 means the last view starts moving at .5 progress

Parameters:

stagger:

public void setPathMotionArc(int arcMode)

Sets the pathMotionArc for the all motions in this transition. if set to UNSET (default) it reverts to the setting of the constraintSet

Parameters:

arcMode:

public int getPathMotionArc()

gets the pathMotionArc for the all motions in this transition. if set to UNSET (default) it reverts to the setting of the constraintSet

Returns:

arcMode

public boolean isEnabled()

Returns true if this Transition can be auto considered for transition Default is enabled

public void setEnabled(boolean enable)

enable or disable the Transition. If a Transition is disabled it is not eligible for automatically switching to.

Parameters:

enable:

public java.lang.String debugString(Context context)

Print a debug string indicating the starting and ending state of the transition

Parameters:

context:

Returns:

public boolean isTransitionFlag(int flag)

is the transition flag set

Parameters:

flag:

Returns:

public void setTransitionFlag(int flag)

public void setOnTouchUp(int touchUpMode)

Set the on touch up mode

Parameters:

touchUpMode:

public void setInterpolatorInfo(int interpolator, java.lang.String interpolatorString, int interpolatorID)

Sets the interpolation used for this transition.
The call support standard types EASE_IN_OUT etc.:
setInterpolatorInfo(MotionScene.Transition.INTERPOLATE_EASE_IN_OUT, null, 0); setInterpolatorInfo(MotionScene.Transition.INTERPOLATE_OVERSHOOT, null, 0);
Strings such as "cubic(...)" , "spline(...)"
setInterpolatorInfo( MotionScene.Transition.INTERPOLATE_SPLINE_STRING, "cubic(1,0,0,1)", 0);
Android interpolators in res/anim :
setInterpolatorInfo( MotionScene.Transition.INTERPOLATE_REFERENCE_ID, null, R.anim....);

Parameters:

interpolator: sets the type of interpolation (MotionScene.Transition.INTERPOLATE_*)
interpolatorString: sets a string based custom interpolation
interpolatorID: sets the id of a Android Transition