J'ai une disposition de mouvement avec cette disposition Description: app:layoutDescription="@xml/scene"
scene.xml
<MotionScene
xmlns:motion="http://schemas.Android.com/apk/res-auto">
<Transition
motion:constraintSetStart="@layout/view_home_card_start"
motion:constraintSetEnd="@layout/view_home_card_end"
motion:duration="1000">
<OnSwipe
motion:touchAnchorId="@+id/button"
motion:touchAnchorSide="left"
motion:dragDirection="dragLeft" />
</Transition>
</MotionScene>
Je pense que le xml de view_home_card_start
et view_home_card_end
n'est pas pertinent.
Comment puis-je appeler cette animation par programmation?
Enfin je fais cela:
((MotionLayout)findViewById(R.id.motionLayout)).transitionToEnd();
((MotionLayout)findViewById(R.id.motionLayout)).transitionToStart();
In Latest Update of Constraint **2.0.0-beta1** Layout There are Public methods add in motion layout
you can get these methods with the help of motionlayout id
**motionLayout**
1. public void setProgress (float pos)
2. public void setTransition (int
beginId,int endId)
3. public void setTransitionDuration (int
milliseconds) public void setTransitionListener
(MotionLayout.TransitionListener listener)
4. public void setState (int
id,int screenWidth,
int screenHeight)
5. if(wantShowUi)
{
newUserActivityBinding.coordinatorLayout.transitionToStart();
}
else
{
newUserActivityBinding.coordinatorLayout.transitionToEnd();
}
<Android.support.constraint.motion.MotionLayout
xmlns:Android="http://schemas.Android.com/apk/res/Android"
xmlns:app="http://schemas.Android.com/apk/res-auto"
xmlns:tools="http://schemas.Android.com/tools"
Android:id="@+id/motionLayout"
Android:layout_width="match_parent"
Android:layout_height="match_parent"
app:layoutDescription="@xml/motion_scene_01"
tools:showPaths="true">
<View
Android:id="@+id/button"
Android:background="@color/colorAccent"
Android:layout_width="match_parent"
Android:layout_height="wrap_content"
Android:soundEffectsEnabled="false"
tools:layout_editor_absoluteY="361dp"
tools:layout_editor_absoluteX="61dp"/>
</Android.support.constraint.motion.MotionLayout>