MotionLayout的动画制作不流畅

问题描述

我有一个Fragment,其布局由一个有两个子级的MotionLayout组成。一个孩子是水平RecyclerView,另一个孩子是FrameLayout。它们是垂直堆叠的。

MotionLayout
--RecyclerView (horizontal)
--FrameLayout

FrameLayout内是ViewPager -每页是一个带有垂直Fragment的{​​{1}}。我希望此垂直RecyclerView的滚动像水平RecyclerView一样将FrameLayout折叠/展开到水平RecyclerView上。

很容易在以下场景中实现此“工作”:

CollapsingToolbarLayout

此“有效”。 <?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捕捉立即折叠/展开。

有人可以告诉我我在做什么错吗?

谢谢

解决方法

尝试将app:touchAnchorSide更改为底部

,

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

如果希望折叠的动画跟随滚动,请尝试将app:onTouchUp="autoComplete"更改为app:onTouchUp="stop"

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...