0

I have a MotionLayout transition with motioninterpolator set with a cubic-bezier function:

    <Transition
        android:id="@+id/transition01"
        motion:constraintSetStart="@+id/start"
        motion:constraintSetEnd="@+id/end"
        motion:motionInterpolator="cubic(.81,.1,.92,1.4)"
        motion:duration="1000">

I am expecting at the end of the transition to have like a "spring" effect at the end of the animation just as shown here: https://cubic-bezier.com/#.81,.1,.92,1.4

But at the end of the animation, the target view just sticks to the final constraints without doing the bounce back effect.

I have also tried motion:motionInterpolator="cubic-bezier(.81,.1,.92,1.4)" without any success.

Does anyone know how I can achieve this with MotionLayout? Thanks for any clue.

here is the version I am using:

implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
Raphael C
  • 2,296
  • 1
  • 22
  • 22
  • You should state which version of the library you are using: https://developer.android.com/jetpack/androidx/releases/constraintlayout – Morrison Chang Mar 11 '21 at 09:52
  • @MorrisonChang I added the version in the question. it's 2.0.4 – Raphael C Mar 11 '21 at 10:10
  • 1
    Found that from the [source - line 594](https://github.com/androidx/constraintlayout/blob/main/constraintlayout/constraintlayout/src/main/res/values/attrs.xml#L594) is only a linear cubic-bezier so parameters can only go from 0 to 1. There a whole [Android section on spring animation](https://developer.android.com/guide/topics/graphics/spring-animation) if you want bounce. – Morrison Chang Mar 11 '21 at 11:26
  • @MorrisonChang thanks. so I understand this is not possible using MotionLayout. I do know about the Spring animation dependency, although I would have preferred using it in MotionLayout because it can coordinate a lot of my animations easily, and I really don't want to re-write everything. oh well... – Raphael C Mar 11 '21 at 12:03

1 Answers1

1

CL 2.0 does not support overshoot interpolation (technically extrapolation) . So the output was capped from 0 to 1.

2.1 does support interpolation. So this will work in 2.1 (currently in alpha)

hoford
  • 4,918
  • 2
  • 19
  • 19