I am using MotionLayout to achieve a simple animation: I have two views inside my MotionLayout, a bar constrained to top and a RecyclerView constrained to the bottom of the bar. When I am scrolling the RecyclerView, the top view should be pushed out. (Like a collapsing toolbar) My MotionScene looks like the following:
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@+id/start">
<OnSwipe
motion:dragDirection="dragUp"
motion:moveWhenScrollAtTop="false"
motion:touchAnchorId="@+id/table_view" />
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/table_view"
android:layout_width="0dp"
android:layout_height="0dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toBottomOf="@+id/filters" />
<Constraint
android:id="@+id/filters"
android:layout_width="0dp"
android:layout_height="48dp"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/table_view"
android:layout_width="0dp"
android:layout_height="0dp"
motion:layout_constraintBottom_toBottomOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
<Constraint
android:id="@+id/filters"
android:layout_width="0dp"
android:layout_height="48dp"
android:translationY="-48dp"
motion:layout_constraintEnd_toEndOf="parent"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>
The filters is the top view and the table_view is the RecyclerView. The animation is working like a charm with only a pretty big glitch. When I first enter the screen and start dragging the RecyclerView down, the whole top view is disappearing. If I start scrolling up, everything is back to normal and I cannot reproduce the glitch anymore. I don't know if I am doing something wrong, or there is a bug in the MotionLayout.
Notes: I needed the transitionY for specific purposes. If I change the OnSwipe direction to dragDown, the same thing is happening when I start to scroll up.