创建 AnimatedVectorDrawable 的工具

问题描述 投票:0回答:4

我真的很喜欢 Android 中添加的 AnimatedVectorDrawable 功能。 有什么好的工具可以创建这样的动画吗?

例如任何创建动画的工具如此处所述enter image description here

编辑:

到目前为止,我已经找到了这些工具(有点帮助):

android android-animation material-design android-vectordrawable
4个回答
35
投票

发现两个很棒的网站。 AndroidIconAnimator,这是一个基于 Web 的工具,用于创建 AnimatedVectorDrawables。还有 Shapeshifter,可以很好地控制如何变形路径。

更新 07-09-2017

这两种工具现在已合并为一个非常好的解决方案。我花了一些时间才了解如何使用它,但是一旦你看到它,它就是一个非常强大的工具

Shapeshifter.design

感谢 2 Roman Nurik 和 Alex Lockwood。


2
投票

这个问题很老了。我的回答可能会对未来的读者有所帮助。

创建像提问者展示的那样的动画非常简单。我们自己可以创建如图所示的动画。首先,创建一个 VectorDrawable。例如下面:

my_vector_drawable.xml

<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="800dp"
        android:height="800dp"
        android:viewportWidth="800.0"
        android:viewportHeight="800.0">

    <path
        android:name="a_circle"
        android:pathData="M  250   200
        q   -86     02    -140     57.5
        t   -57    135.5
        q   -03     93      67    156
        q    59     52     135     50
        q    71    -02     132    -54
        q    66    -56      66   -146
        q    00    -80     -45   -129
        q   -68    -72    -158    -70   "

        android:strokeLineCap="round"
        android:strokeColor="#f00f"
        android:fillColor="#00000000"
        android:trimPathEnd="0"
        android:strokeWidth="32"/>



</vector>

my_animated_vector_drawable.xml

<?xml version="1.0" encoding="utf-8"?>
<animated-vector
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:aapt="http://schemas.android.com/aapt"
    android:drawable="@drawable/my_vector_drawable">

    <target
        android:name="a_circle"
        android:animation="@animator/my_animation"/>

</animated-vector>

我的动画.xml

<?xml version="1.0" encoding="utf-8"?>
<set
    xmlns:android="http://schemas.android.com/apk/res/android">
    <objectAnimator
        android:propertyName="trimPathEnd"
        android:duration="1000"
        android:valueFrom="0"
        android:valueTo="1"
        android:repeatCount="0"
        android:repeatMode="restart"/>
</set>

第一个文件包含图片数据。第三个文件包含动画数据。第二个文件链接第一个和第二个文件。

您可以创建三个空白文件。将上面给出的内容复制并粘贴到您的文件中。

将前两个文件放入可绘制文件夹中。第三个放在“animator”文件夹中。这两个文件夹都位于 res 文件夹中。

您可以创建一个包含 ImageView 的布局文件。您可以将 AnimatedVectorDrawable 文件作为可绘制对象 (android:src="my_animated_vector_drawable")。

在您的活动中将内容视图设置为布局。另外,膨胀 ImageView。

(myImage=((ImageView)findViewById(R.id.yourimageview name);
myImage.getDrawable.start():

那就看看好玩的吧。 AnimatedVectorDrawable 文件中可以有多个目标。你可以在set下的动画文件中拥有多个ObjectAnimators...

您问题中显示的动画是路径变形。文档中甚至有路径变形示例,这也很简单。我把它留给你去实验。


1
投票

您可以使用 Airbnb 的lottie 库。它使得将 After Effects 中的动画设计路径传送到适用于 Android 的动画矢量绘图。我认为,如果您拥有在 After Effects 中制作矢量路径动画的良好技能,那么这将是最好的解决方案,因为它具有灵活性。

这里有一个视频,描述了转换和渲染的完整过程 https://www.youtube.com/watch?v=vs6GOlgUSc8

Airbnb 的洛蒂图书馆

一些使用 Lottie 设计的动画图标。

enter image description here

布局中使用的动画图标

enter image description here


0
投票

抱歉回复晚了。你可以使用我的工具将你的lottiefiles动画转换为android动画矢量绘图link

通过运行安装它:

npm install -g lottie-to-avd

然后运行:

lottie-to-avd -i sample.json -o sample.xml
© www.soinside.com 2019 - 2024. All rights reserved.