Итак, мы пытаемся имитировать поведение «1001 *» («нижний вид», выглядывающий из нижней части экрана, который появляется в полноэкранном режиме при прокрутке вверх), примерно так: https://www.youtube.com/watch?v=yrZVLL-z6P4) с использованием MotionLayout
, версия 2.0.0-alpha4
.
Проблема в том, что переход OnSwipe
в режиме просмотра с возможностью просмотра не относится к самому представлению, он, по-видимому, относится ко всему представлению внизу, в данном случае RecyclerView
. Поэтому, когда мы прокручиваем RecyclerView
, переход выполняется.
root_view.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>
motion_scene.xml
<Transition
android:id="@+id/swipe"
app:constraintSetEnd="@id/end"
app:constraintSetStart="@id/start"
app:duration="250">
<OnSwipe
app:dragDirection="dragUp"
app:touchAnchorId="@id/btn" />
</Transition>
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@id/fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="parent" />
<Constraint
android:id="@id/btn"
android:layout_width="match_parent"
android:layout_height="@dimen/size_48"
app:layout_constraintBottom_toBottomOf="parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/fragment"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn" />
<Constraint
android:id="@id/btn"
android:layout_width="match_parent"
android:layout_height="@dimen/size_48"
app:layout_constraintTop_toTopOf="parent" />
</ConstraintSet>