gpt4 book ai didi

android - 运动布局 : how to animate margin

转载 作者:行者123 更新时间:2023-11-30 05:05:43 27 4
gpt4 key购买 nike

我正在使用 MotionLayout 将 View 的大小从全屏调整为具有特定边距的较小尺寸的动画(如下所示)。它大部分工作正常,但显示的边距为 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 例如边距会逐渐改变。

最佳答案

SurfaceView 不允许适当的转换,如果你需要转换你应该使用 TextureView。

关于android - 运动布局 : how to animate margin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54635533/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com