因此,我们试图模仿可窥视BottomSheetLayout
的行为(从屏幕底部窥视的底部视图,向上滚动时会进入全屏视图,如下所示:[ C0]),使用https://www.youtube.com/watch?v=yrZVLL-z6P4版本MotionLayout
。
问题在于,可窥视视图上的2.0.0-alpha4
过渡不适用于视图本身,显然适用于其下的整个视图,在本例中为OnSwipe
。因此,当我们滚动RecyclerView
时,过渡正在运行。
root_view.xml
RecyclerView
motion_scene.xml
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.motion.widget.MotionLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/motion_scene">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:clipToPadding="false"
android:paddingBottom="@dimen/margin_48"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/btn"
android:layout_width="match_parent"
android:layout_height="@dimen/size_48"
android:elevation="@dimen/elevation_12"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="@dimen/elevation_12"
android:rotation="90"
app:layout_constraintBottom_toBottomOf="@id/btn"
app:layout_constraintEnd_toEndOf="@id/btn"
app:layout_constraintTop_toTopOf="@id/btn" />
<FrameLayout
android:id="@+id/fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="@dimen/elevation_8"
app:layout_constraintTop_toBottomOf="parent" />
</androidx.constraintlayout.motion.widget.MotionLayout>
</FrameLayout>
您必须禁用嵌套滚动,以阻止Recyclerview触发动画。执行以下操作,您就可以了:)