将RecyclerView touch传递给MotionLayout不起作用

问题描述

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

enter image description here

这是我的布局代码:

<?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>

这是我的场景代码:

<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>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...