我正在使用MotionLayout做一个示例,我只想在滚动时调整图像大小。问题是动画结束时底边距比动画开始前大。如何解决该问题,并在开始和结束动画时获得相同的边距。
<MotionScene
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:motion="http://schemas.android.com/apk/res-auto">
<Transition
motion:constraintSetEnd="@+id/end"
motion:constraintSetStart="@+id/start"
motion:duration="1000"
motion:motionInterpolator="linear">
<OnSwipe
motion:touchAnchorId="@+id/llcontainer"
motion:touchAnchorSide="bottom"
motion:dragDirection="dragUp"/>
</Transition>
<ConstraintSet android:id="@+id/start"/>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@id/card_img"
android:layout_width="0dp"
android:layout_height="80dp"
android:layout_marginBottom="0dp"/>
</ConstraintSet>
<android.support.constraint.motion.MotionLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:showPaths="false"
app:layoutDescription="@xml/card_motion"
android:orientation="vertical">
<ImageView
android:id="@+id/card_img"
android:layout_width="match_parent"
android:layout_height="227dp"
android:src="@drawable/mario"
android:layout_centerInParent="true"
android:foregroundGravity="center_vertical"
android:scaleType="centerInside"
android:layout_marginTop="24dp"
android:layout_marginBottom="24dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/llcontainer" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="400dp"
android:background="@color/colorPrimaryDark"
android:orientation="vertical"
android:id="@+id/llcontainer"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/card_img"/>
</android.support.constraint.motion.MotionLayout>