我有一个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
捕捉立即折叠/展开。
有人可以告诉我我在做什么错吗?
谢谢
答案 0 :(得分:0)
尝试将app:touchAnchorSide
更改为底部
答案 1 :(得分:0)
snaps collapsed/expanded
是app:onTouchUp="autoComplete"
的预期行为。
如果希望折叠的动画跟随滚动,请尝试将app:onTouchUp="autoComplete"
更改为app:onTouchUp="stop"
。