MotionHelper
public class MotionHelper extends ConstraintHelper implements MotionHelperInterface
| java.lang.Object | |||
| ↳ | android.view.View | ||
| ↳ | androidx.constraintlayout.widget.ConstraintHelper | ||
| ↳ | androidx.constraintlayout.motion.widget.MotionHelper |
Carousel |
Carousel works within a MotionLayout to provide a simple recycler like pattern. |
MotionEffect |
MotionHelper that automatically inserts keyframes for views moving in a given direction, out of: |
Summary
Protected fields |
|
|---|---|
View[] |
Public constructors |
|---|
MotionHelper(Context context) |
MotionHelper(Context context, AttributeSet attrs) |
MotionHelper(Context context, AttributeSet attrs, int defStyleAttr) |
Public methods |
|
|---|---|
float |
get the progress |
boolean |
is involved in painting |
boolean |
|
boolean |
|
void |
onFinishedMotionScene(MotionLayout motionLayout)This is called after motionLayout read motionScene and assembles all constraintSets |
void |
onPostDraw(Canvas canvas)Called after views are painted |
void |
Call before views are painted |
void |
onPreSetup(Called after motionController is populated with start and end and keyframes. |
void |
onTransitionChange(Called when a drawer's position changes. |
void |
onTransitionCompleted(MotionLayout motionLayout, int currentId)Called when a drawer has settled completely a state. |
void |
onTransitionStarted(MotionLayout motionLayout, int startId, int endId)Called when a drawer is about to start a transition. |
void |
onTransitionTrigger(Call when a trigger is fired |
void |
setProgress(float progress)Set the progress |
void |
setProgress(View view, float progress) |
Protected methods |
|
|---|---|
void |
init(AttributeSet attrs) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited methods |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
MotionHelper
public MotionHelper(Context context, AttributeSet attrs, int defStyleAttr)
Public methods
onFinishedMotionScene
public void onFinishedMotionScene(MotionLayout motionLayout)
This is called after motionLayout read motionScene and assembles all constraintSets
| Parameters | |
|---|---|
MotionLayout motionLayout |
onPostDraw
public void onPostDraw(Canvas canvas)
Called after views are painted
| Parameters | |
|---|---|
Canvas canvas |
onPreDraw
public void onPreDraw(Canvas canvas)
Call before views are painted
| Parameters | |
|---|---|
Canvas canvas |
onPreSetup
public void onPreSetup(
MotionLayout motionLayout,
HashMap<View, MotionController> controllerMap
)
Called after motionController is populated with start and end and keyframes.
| Parameters | |
|---|---|
MotionLayout motionLayout |
|
HashMap<View, MotionController> controllerMap |
onTransitionChange
public void onTransitionChange(
MotionLayout motionLayout,
int startId,
int endId,
float progress
)
Called when a drawer's position changes.
| Parameters | |
|---|---|
MotionLayout motionLayout |
The TransitionLayout view that was moved |
int startId |
the id of the start state (or ConstraintSet). Will be -1 if unknown. |
int endId |
the id of the end state (or ConstraintSet). |
float progress |
The progress on this transition, from 0 to 1. |
onTransitionCompleted
public void onTransitionCompleted(MotionLayout motionLayout, int currentId)
Called when a drawer has settled completely a state. The TransitionLayout is interactive at this point.
| Parameters | |
|---|---|
MotionLayout motionLayout |
Drawer view that is now open |
int currentId |
the id it has reached |
onTransitionStarted
public void onTransitionStarted(MotionLayout motionLayout, int startId, int endId)
Called when a drawer is about to start a transition. Note. startId may be -1 if starting from an "undefined state"
| Parameters | |
|---|---|
MotionLayout motionLayout |
The TransitionLayout view that was moved |
int startId |
the id of the start state (or ConstraintSet). Will be -1 if unknown. |
int endId |
the id of the end state (or ConstraintSet). |
onTransitionTrigger
public void onTransitionTrigger(
MotionLayout motionLayout,
int triggerId,
boolean positive,
float progress
)
Call when a trigger is fired
| Parameters | |
|---|---|
MotionLayout motionLayout |
|
int triggerId |
The id set set with triggerID |
boolean positive |
for positive transition edge |
float progress |
setProgress
public void setProgress(float progress)
Set the progress
| Parameters | |
|---|---|
float progress |
setProgress
public void setProgress(View view, float progress)
| Parameters | |
|---|---|
View view |
|
float progress |