Search code examples
androidanimationandroid-recyclerviewandroid-motionlayout

Android MotionLayout + Recyclerview, views in recyclerview not clickable


I'm playing a RecyclerView with MotionLayout, and the structure in .xml is like

<ConstraintLayout>

    <MotionLayout>

        <OtherView...>

        <RecylerView>

        </RecylerView>

    </MotionLayout>

</ConstraintLayout>

A behavior of MotionLayout is when dragging MotionLayout up and down, RecyclerView follows which scales up and down to the top-side

Everything is working fine except that views in RecyclerView are not clickable for a few secs after very quick scrolling from RecyclerView. I thought it was probably from some rendering issues because everytime scrolling up and down, the positions of views in RecyclerView are replaced too. The version of MotionLayout that I'am using is 2.0.1,

<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <!-- 1 -->
    <Transition
        app:constraintSetEnd="@id/end"
        app:constraintSetStart="@id/start"
        app:duration="1000">

        <OnSwipe
            app:dragDirection="dragUp"
            app:touchAnchorId="@+id/rvContent"
            app:touchAnchorSide="top" />

    </Transition>

    <!-- 2 -->
    <ConstraintSet android:id="@+id/start">
        <Constraint android:id="@id/txtTitle">
            <PropertySet app:alpha="1" />
        </Constraint>
        <Constraint android:id="@id/txtSubtitle">
            <PropertySet app:alpha="1" />
        </Constraint>
    </ConstraintSet>

    <Some Other ConstraintSet...>

</MotionLayout>

Can anyone give me some workaround? thanks.


Solution

  • Ok, I've fixed this bug. The bug is from the compatibility between recyclerview and motionlayot. Just make your recyclerview version to the latest one.