gpt4 book ai didi

android - AutoTransition 在 Motion 布局中不起作用

转载 作者:行者123 更新时间:2023-12-04 23:52:35 29 4
gpt4 key购买 nike

我目前正在学习motionlayout。我创建了一个小应用程序,其中中心的图像旋转 5 秒。 onClick 和 onSwipe 属性在设备上运行良好,但是当我在设备上运行应用程序时,autotransition = animateToEnd 没有发生任何事情。基本上我希望我的过渡在 Activity 开始时自动发生。
这是我的运动布局文件:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.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:layoutDescription="@xml/activity_main_scene">

<ImageView
android:id="@+id/back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="TODO"
android:src="@drawable/background" />

<ImageView
android:id="@+id/moon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/ic_moon"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.motion.widget.MotionLayout>

这是我的运动场景:
<?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:constraintSetEnd="@+id/end"
motion:constraintSetStart="@id/start"
motion:duration="5000"
motion:autoTransition="animateToEnd">
<KeyFrameSet>
<KeyCycle
motion:motionTarget="@+id/moon"
motion:framePosition="0"
motion:wavePeriod="2"
motion:waveShape="sawtooth"
android:rotation="180"
motion:waveOffset="0" />
</KeyFrameSet>
</Transition>

<ConstraintSet android:id="@+id/start">
</ConstraintSet>

<ConstraintSet android:id="@+id/end">
</ConstraintSet>
</MotionScene>

如果有任何其他方法可以通过运动布局运行过渡,请告知。
**为了运行我用来创建调试 apk 的应用程序,然后在我的设备上运行它。

最佳答案

只需添加

app:motionInterpolator="linear"
到过渡标签

关于android - AutoTransition 在 Motion 布局中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62427755/

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