在 Android Studio 中制作动画

Make an Animation in Android Studio

我知道如何在 Android studio 中创建逐帧动画。我一直在使用 Paint 创建一堆图像并上传它们以创建自定义动画。

但是,必须有更好的方法来做到这一点吗?我可以使用某些 2-D 动画软件创建动画然后将其上传到 android studio 吗?

任何thoughts/suggestions关于如何有效地制作自定义动画(例如,一个人运行)?

你可以看看 Lottie,也许:https://airbnb.design/lottie/(支持 android 和 ios)它也极大地改进和增强了这些动画(它将它们转换为更小的 Json 个文件)。

这里有一些您可以用它做什么的例子:https://lottiefiles.com/

它仅适用于小 gif 和加载动画,但您可以使用 Adob​​e After Effects 创建自己的动画,也许这会有所帮助

如果你只有几张图片,那么做起来很简单,你只需要在 drawable 文件夹中创建资源文件,只需使用 <animation-list> 标签并将所有图片添加为 <item android:drawable="@drawable/seq1" android:duration="100">延迟。就像 official docs 中提到的那样。 例如:

<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/selected" android:oneshot="false">
    <item android:drawable="@drawable/ic_camera_arrow_00001" android:duration="200" />
    <item android:drawable="@drawable/ic_camera_arrow_00002" android:duration="200" />
    <item android:drawable="@drawable/ic_camera_arrow_00003" android:duration="200" />
    <item android:drawable="@drawable/ic_camera_arrow_00004" android:duration="200" />
</animation-list>

val frameAnimation = imageView?.drawable as AnimationDrawable
frameAnimation.start()