使 MotionLayout Transition 具有恒定速度

Make MotionLayout Transition to have a constant speed

我怎样才能使我的自动转换具有恒定速度? 它总是开始缓慢,然后随着它的进行而加速,然后在即将完成过渡时变慢,我希望从开始到结束的速度相同。

<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>

您可以使用 TransitionmotionInterpolator 属性。只需将其设置为“线性”

<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>