我正在使用MotionLayout
动画将视图的大小从全屏调整为具有特定边距的较小尺寸(如下所示)。它大部分工作正常,但显示的边距为 0,直到动画结束,然后立即应用它们。有什么办法也可以为这些设置动画吗?
<ConstraintSet android:id="@+id/start">
<Constraint
android:id="@+id/localVideoView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ConstraintSet>
<ConstraintSet android:id="@+id/end">
<Constraint
android:id="@+id/localVideoView"
android:layout_width="68dp"
android:layout_height="120dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="16dp"
android:layout_marginBottom="92dp"/>
</ConstraintSet>
我尝试使用KeyFrameSet
创建具有不同边距值的中间点,但这没有效果。
例如
<KeyFrameSet>
<KeyAttribute
app:framePosition="50"
app:target="@id/localVideoView">
<CustomAttribute
motion:attributeName="layoutMarginBottom"
motion:customDimension="92dp" />
</KeyAttribute>
</KeyFrameSet>
更新
所以,看起来问题与我正在使用的事实有关SurfaceView
......如果我尝试使用ImageView
例如边距确实会逐渐变化。