Make MotionLayout Transition to have a constant speed

Viewed 291

How can I make my automatic transition to have a constant speed? It always starts slowly and speeds up as it progress, then it slows down when is about to finish the transition, I want the speed to be the same from the beginning and until the end.

<Transition
    app:duration="@integer/long_duration"
    app:autoTransition="animateToEnd"
    app:constraintSetEnd="@id/end"
    app:constraintSetStart="@+id/start">

    <KeyFrameSet>
        <KeyAttribute
            app:motionTarget="@id/animated_view"
            android:alpha="1" />
    </KeyFrameSet>
</Transition>
1 Answers

You can use a motionInterpolator property of your Transition. Just set it to "linear"

<Transition
    app:duration="@integer/long_duration"
    app:autoTransition="animateToEnd"
    app:constraintSetEnd="@id/end"
    app:constraintSetStart="@+id/start"

    app:motionInterpolator="linear"> <!-- this is the trick -->

    <KeyFrameSet>
        <KeyAttribute
            app:motionTarget="@id/animated_view"
            android:alpha="1" />
    </KeyFrameSet>
</Transition>
Related