我有一个Fragment
,其布局包括一个 MotionLayout
,其中有两个子元素。一个子元素是一个水平的RecyclerView
,另一个子元素是一个FrameLayout
。它们被垂直地堆叠在一起。
MotionLayout
--RecyclerView (horizontal)
--FrameLayout
在
FrameLayout
中有一个ViewPager
,每个页面都是一个具有垂直RecyclerView
的Fragment
。 我想让这个垂直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
立即折叠/展开,没有平滑过渡。
请问有人能告诉我在这里做错了什么吗?
谢谢