为什么Swipe上的运动布局不起作用



我使用的是运动布局,当我设置滑动到图像视图时,它不起作用。我有两个过渡期。第一个转换是针对回收器视图,我设置了滑动,它可以工作

这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<MotionScene 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<ConstraintSet android:id="@+id/image_start" />
<ConstraintSet android:id="@+id/image_end">
<Constraint
android:layout_height="wrap_content"
motion:layout_constraintStart_toStartOf="parent"
motion:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:id="@+id/space"
motion:layout_constraintBottom_toBottomOf="@+id/mainRv" />
<Constraint
android:id="@+id/floatingActionButton"
android:elevation="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
motion:layout_constraintTop_toTopOf="parent"
motion:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="32dp"
android:alpha="0" />
</ConstraintSet>
<Transition
motion:constraintSetStart="@+id/image_start"
motion:constraintSetEnd="@+id/image_end" >
<KeyFrameSet>
</KeyFrameSet>
<OnSwipe
motion:touchAnchorId="@+id/mainRv"/>
</Transition>
</MotionScene>

我用了这个过渡。但不工作

<Transition
motion:constraintSetStart="@+id/image_start"
motion:constraintSetEnd="@+id/image_end" >
<OnSwipe
motion:touchAnchorId="@+id/mainRv"
motion:dragDirection="dragDown"
motion:touchAnchorSide="bottom" />
</Transition>

这是我的动作布局图(末端过渡有问题(

注意:转换时间线工作正常。

这是起始位置图片这是末端位置图片(回收器视图向下拖动(

首先总是设置启动约束,因为它会在某些设备中导致一些错误。为了解决你的问题,可以用方向和触球的方式进行测试。设置dragUp和top以及其他情况。

最新更新