将 RecyclerView 触摸传递给 MotionLayout 不起作用

Raf*_*ael 5 android android-recyclerview android-motionlayout

我在图片上有如下布局。对于动画,我使用 MotionLayout。当用户触摸搜索时,我会向上滚动视图,因此搜索成为最顶部的视图。在搜索下。我在 RecyclerView 中有项目列表。我想通过向下滚动列表项来恢复向上滚动。但我找不到办法做到这一点。我无法从 Recyclerview 获得触摸事件。

在此处输入图片说明

这是我的布局代码:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/manage_wallets"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:showPaths="true"
    app:layoutDescription="@xml/manage_wallets_fragment_scene">

    <com.example.views.ShadowlessToolbarView
        android:id="@+id/customToolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.example.views.CoinSearchView
        android:id="@+id/searchView"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginStart="16dp"
        android:layout_marginEnd="16dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/customToolbar" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_marginTop="12dp"
        android:clipToPadding="false"
        android:paddingBottom="32dp"
        android:nestedScrollingEnabled="false"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/searchView"
        tools:itemCount="4"
        tools:listitem="@layout/view_holder_item" />

</androidx.constraintlayout.motion.widget.MotionLayout>
Run Code Online (Sandbox Code Playgroud)

这是我的场景代码:

<ConstraintSet android:id="@+id/start">
    <Constraint android:id="@+id/customToolbar" />
</ConstraintSet>

<ConstraintSet android:id="@+id/end">
    <Constraint android:id="@+id/customToolbar"
        android:layout_height="0dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:layout_width="match_parent"
        app:layout_constraintBottom_toTopOf="parent" />
</ConstraintSet>

<Transition
    app:constraintSetEnd="@+id/end"
    app:constraintSetStart="@+id/start" >
    <OnClick
        app:targetId="@+id/searchView"
        app:clickAction="transitionToEnd"/>
</Transition>
<Transition
    app:constraintSetStart="@+id/start"
    app:constraintSetEnd="@+id/end" >
    <OnSwipe
        motion:touchAnchorId="@+id/recyclerView"
        motion:touchAnchorSide="top"
        motion:dragDirection="dragDown" />
</Transition>
Run Code Online (Sandbox Code Playgroud)