MotionLayout动画不流畅

3

我有一个Fragment,其布局包括一个 MotionLayout,其中有两个子元素。一个子元素是一个水平的RecyclerView,另一个子元素是一个FrameLayout。它们被垂直地堆叠在一起。

MotionLayout
--RecyclerView (horizontal)
--FrameLayout

FrameLayout中有一个ViewPager,每个页面都是一个具有垂直RecyclerViewFragment。 我想让这个垂直RecyclerView的滚动能够像CollapsingToolbarLayout一样,折叠/展开覆盖在水平RecyclerView上的FrameLayout
使用以下场景可以轻松实现这个效果:
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <Transition
        app:constraintSetEnd="@+id/collapsed"
        app:constraintSetStart="@+id/expanded">

        <OnSwipe
            app:dragDirection="dragDown"
            app:onTouchUp="autoComplete"
            app:touchAnchorId="@+id/vertical_recycler_view"
            app:touchAnchorSide="top" />

    </Transition>

    <ConstraintSet android:id="@+id/expanded">

        <Constraint
            android:id="@id/my_framelayout"
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/horizontal_recycler_view" />

    </ConstraintSet>

    <ConstraintSet android:id="@+id/collapsed">

        <Constraint
            android:id="@id/my_framelayout"
            android:layout_width="0dp"
            android:layout_height="0dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </ConstraintSet>

</MotionScene>

这个"可以工作". FrameLayout 可以如预期般在水平 RecyclerView 上“折叠”。

我的问题是动画不流畅(随着时间的推移)。FrameLayout 立即折叠/展开,没有平滑过渡。

请问有人能告诉我在这里做错了什么吗?

谢谢


1
你找到解决方案了吗? - Luiz Filipe Medeira
这里也有同样的问题... - Crisic
3个回答

1
"

snaps collapsed/expandedapp:onTouchUp="autoComplete"的预期行为。

如果你想让折叠动画跟随滚动,尝试将app:onTouchUp="autoComplete"更改为app:onTouchUp="stop"

"

0
尝试将app:touchAnchorSide更改为底部。

0

只需将 app:dragDirection="dragDown" 更改为 app:dragDirection="dragUp"


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接