androidx / constraintlayout

ConstraintLayout is an Android layout component which allows you to position and size widgets in a flexible way
Apache License 2.0
1.06k stars 177 forks source link

MotionLayout bug with Recyclerview ( setTransition programmatically and back, Recyclerview Scroll did not attach to MotionLayout OnSwipe ) #849

Open aadilmirrani opened 6 months ago

aadilmirrani commented 6 months ago

ConstraintLayout version: 2.1.4 Recyclerview: 1.3.1

In my Android app. I have a layout consisting of an ImageView and a NestedScrollView within a ConstraintLayout. The layout is designed with three ConstraintSet states: constraints_start, constraints_end, and constraints_search.

I have set up a transition between constraints_start and constraints_end, which is triggered by a swipe gesture on the header or NestedScrollView. The XML for this transition is as follows:

<Transition motion:constraintSetEnd="@id/constraints_end" motion:constraintSetStart="@id/constraints_start" motion:duration="300" motion:motionInterpolator="linear" motion:layoutDuringTransition="honorRequest"> <OnSwipe motion:dragDirection="dragUp" motion:onTouchUp="decelerate" motion:touchAnchorId="@id/nsv_gf_list" motion:touchAnchorSide="top" />

The issue I'm facing is that when I programmatically set the transition state using setTransition or transitionToState, the NestedScrollView seems to scroll on its own, and the MotionLayout transition doesn't trigger immediately. However, it works as intended if I manually scroll on the header after setting the transition programmatically.

Steps to Reproduce:

Programmatically set the transition state using setTransition or transitionToState. Observe that the NestedScrollView starts scrolling on its own. Manually scroll on the header After the manual scroll, the MotionLayout transition triggers as expected. Expected Behavior:

The MotionLayout transition should be triggered programmatically without the need for a manual scroll on the header or NestedScrollView.