Android 第一次触摸时MotionLayout出现视觉故障

Android 第一次触摸时MotionLayout出现视觉故障,android,android-animation,android-motionlayout,Android,Android Animation,Android Motionlayout,我正在使用com.android.support.constraint:constraint-layout:2.0.0-alpha2软件包中的新MotionLayout 但是我看到了一个视觉上的小故障,它发生在我第一次触摸屏幕的时候。我已经为dragDirection=“dragDown”实现了onswip,但是如果我在任何其他动作之前进行了一次向上拖动,它将显示动画的结束状态。 不幸的是,我无法上传GIF,因为它太大了。所以我附上了所有的代码: 编辑 附上录影带- 场景_03.xml <

我正在使用
com.android.support.constraint:constraint-layout:2.0.0-alpha2
软件包中的新
MotionLayout

但是我看到了一个视觉上的小故障,它发生在我第一次触摸屏幕的时候。我已经为
dragDirection=“dragDown”
实现了
onswip
,但是如果我在任何其他动作之前进行了一次向上拖动,它将显示动画的结束状态。 不幸的是,我无法上传GIF,因为它太大了。所以我附上了所有的代码:

编辑 附上录影带-

场景_03.xml

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

  <Transition
      motion:constraintSetStart="@+id/start"
      motion:constraintSetEnd="@+id/end"
      motion:duration="10000">

    <OnSwipe
        motion:touchAnchorId="@+id/hpImage"
        motion:touchAnchorSide="bottom"
        motion:dragDirection="dragDown" />
  </Transition>

  <ConstraintSet android:id="@+id/start">
    <Constraint
        android:id="@+id/hpImage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        android:adjustViewBounds="true"
        motion:layout_constraintStart_toStartOf="parent"
        motion:layout_constraintEnd_toEndOf="parent"
        motion:layout_constraintTop_toTopOf="parent"
        />

    <Constraint
        android:id="@+id/tvHp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="12dp"
        android:layout_marginBottom="12dp"
        android:textSize="24sp"
        android:scaleX="1"
        android:scaleY="1"
        android:text="Harry Potter"
        android:textColor="#fff"
        motion:layout_constraintStart_toStartOf="@+id/hpImage"
        motion:layout_constraintBottom_toBottomOf="@+id/hpImage"
        />

  </ConstraintSet>

  <ConstraintSet android:id="@+id/end">
    <Constraint
        android:id="@+id/hpImage"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:scaleType="centerCrop"
        android:adjustViewBounds="true"
        android:visibility = "invisible"
        motion:layout_constraintStart_toStartOf="parent"
        motion:layout_constraintEnd_toEndOf="parent"
        motion:layout_constraintTop_toTopOf="parent"
      >
    </Constraint>

    <Constraint
        android:id="@+id/tvHp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="0dp"
        android:layout_marginBottom="0dp"
        android:scaleX="0.7"
        android:scaleY="0.7"
        android:gravity="center"
        android:text="Harry Potter"
        android:textColor="#fff"
        motion:layout_constraintStart_toStartOf="@+id/hpImage"
        motion:layout_constraintTop_toTopOf="@+id/hpImage"
        motion:layout_constraintBottom_toBottomOf="@+id/hpImage"
        />
  </ConstraintSet>

</MotionScene>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.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/motionLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layoutDescription="@xml/scene_03"
    android:background="@color/whiteSecondary"
    tools:showPaths="true">

  <View
      android:id="@+id/colorBackground"
      android:layout_width="match_parent"
      android:layout_height="0dp"
      app:layout_constraintStart_toStartOf="@+id/hpImage"
      app:layout_constraintEnd_toEndOf="@+id/hpImage"
      app:layout_constraintTop_toTopOf="@+id/hpImage"
      app:layout_constraintBottom_toBottomOf="@+id/hpImage"
      android:background="@color/colorPrimary"
      />

  <ImageView
      android:id="@+id/hpImage"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:src="@drawable/hp"
      android:scaleType="centerCrop"
      android:adjustViewBounds="true"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      />

  <TextView
      android:id="@+id/tvHp"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginStart="12dp"
      android:layout_marginBottom="12dp"
      android:textSize="24sp"
      android:maxLines="1"
      android:text="Harry Potter"
      android:textColor="#fff"
      app:layout_constraintStart_toStartOf="@+id/hpImage"
      app:layout_constraintBottom_toBottomOf="@+id/hpImage"
      />

</android.support.constraint.motion.MotionLayout>

活动测试.xml

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

  <Transition
      motion:constraintSetStart="@+id/start"
      motion:constraintSetEnd="@+id/end"
      motion:duration="10000">

    <OnSwipe
        motion:touchAnchorId="@+id/hpImage"
        motion:touchAnchorSide="bottom"
        motion:dragDirection="dragDown" />
  </Transition>

  <ConstraintSet android:id="@+id/start">
    <Constraint
        android:id="@+id/hpImage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        android:adjustViewBounds="true"
        motion:layout_constraintStart_toStartOf="parent"
        motion:layout_constraintEnd_toEndOf="parent"
        motion:layout_constraintTop_toTopOf="parent"
        />

    <Constraint
        android:id="@+id/tvHp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="12dp"
        android:layout_marginBottom="12dp"
        android:textSize="24sp"
        android:scaleX="1"
        android:scaleY="1"
        android:text="Harry Potter"
        android:textColor="#fff"
        motion:layout_constraintStart_toStartOf="@+id/hpImage"
        motion:layout_constraintBottom_toBottomOf="@+id/hpImage"
        />

  </ConstraintSet>

  <ConstraintSet android:id="@+id/end">
    <Constraint
        android:id="@+id/hpImage"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:scaleType="centerCrop"
        android:adjustViewBounds="true"
        android:visibility = "invisible"
        motion:layout_constraintStart_toStartOf="parent"
        motion:layout_constraintEnd_toEndOf="parent"
        motion:layout_constraintTop_toTopOf="parent"
      >
    </Constraint>

    <Constraint
        android:id="@+id/tvHp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="0dp"
        android:layout_marginBottom="0dp"
        android:scaleX="0.7"
        android:scaleY="0.7"
        android:gravity="center"
        android:text="Harry Potter"
        android:textColor="#fff"
        motion:layout_constraintStart_toStartOf="@+id/hpImage"
        motion:layout_constraintTop_toTopOf="@+id/hpImage"
        motion:layout_constraintBottom_toBottomOf="@+id/hpImage"
        />
  </ConstraintSet>

</MotionScene>
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.motion.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/motionLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layoutDescription="@xml/scene_03"
    android:background="@color/whiteSecondary"
    tools:showPaths="true">

  <View
      android:id="@+id/colorBackground"
      android:layout_width="match_parent"
      android:layout_height="0dp"
      app:layout_constraintStart_toStartOf="@+id/hpImage"
      app:layout_constraintEnd_toEndOf="@+id/hpImage"
      app:layout_constraintTop_toTopOf="@+id/hpImage"
      app:layout_constraintBottom_toBottomOf="@+id/hpImage"
      android:background="@color/colorPrimary"
      />

  <ImageView
      android:id="@+id/hpImage"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:src="@drawable/hp"
      android:scaleType="centerCrop"
      android:adjustViewBounds="true"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintTop_toTopOf="parent"
      />

  <TextView
      android:id="@+id/tvHp"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginStart="12dp"
      android:layout_marginBottom="12dp"
      android:textSize="24sp"
      android:maxLines="1"
      android:text="Harry Potter"
      android:textColor="#fff"
      app:layout_constraintStart_toStartOf="@+id/hpImage"
      app:layout_constraintBottom_toBottomOf="@+id/hpImage"
      />

</android.support.constraint.motion.MotionLayout>


在constraintlayout的alpha 3版本中可能存在的修复问题

您找到了解决方案吗?我在那里发现了一些东西,但不起作用->