Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start motion scene programmatically

I have a motion layout with this layoutDescription: 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> 

I think that the xml of view_home_card_start and view_home_card_end is irrelevant.

How can I call this animation programatically?

like image 445
Pablo Cegarra Avatar asked Sep 21 '18 06:09

Pablo Cegarra


People also ask

What is MotionLayout?

MotionLayout is a layout type that helps you manage motion and widget animation in your app. MotionLayout is a subclass of ConstraintLayout and builds upon its rich layout capabilities. As part of the ConstraintLayout library, MotionLayout is available as a support library and is backwards-compatible to API level 14.


Video Answer


1 Answers

Finally Im doing this:

((MotionLayout)findViewById(R.id.motionLayout)).transitionToEnd(); ((MotionLayout)findViewById(R.id.motionLayout)).transitionToStart(); 
like image 199
Pablo Cegarra Avatar answered Sep 21 '22 03:09

Pablo Cegarra