动画矢量可绘制动画不起作用
Animated Vector Drawable Animation does not work
我不明白为什么我的 Animated Vector 不工作。我可以看到第一条路径,但我想作为第一条路径的补充的第二条路径没有显示。这是我的代码的样子:
<?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">
<aapt:attr name="android:drawable">
<vector
android:height="24dp"
android:width="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0" >
<path
android:name="v"
android:strokeColor="#000000"
android:strokeWidth="3"
android:pathData="M6,11 l3.5, 4 l0, 0" />
</vector>
</aapt:attr>
<target android:name="v" >
<aapt:attr name="android:animation">
<set>
<objectAnimator
android:duration="1000"
android:propertyName="pathData"
android:valueFrom="M6,11 l3.5, 4 l0, 0"
android:valueTo="M6,11 l3.5, 4 l8, -7"
android:valueType="pathType"/>
</set>
</aapt:attr>
</target>
</animated-vector>
因此,M6,11 l3.5, 4 l0, 0
显示在屏幕上而不是 M6,11 l3.5, 4 l8, -7
我尝试从 google 文档 here 的底部复制示例,但确实有效。如果我使用他们的代码告诉我我正确启动动画,我的文件动画正确。这是拼写错误还是我的路径数据有问题?
我在一个新项目中测试了我的可绘制对象,令我惊讶的是它运行良好。
我在我的第一个项目中使用 com.android.support:design:25.1.0
,结果降级为 com.android.support:design:24.2.0
使它起作用。
经过更多测试后,我发现将 ImageView
上的 app:srcCompat="@drawable/animated_vector"
更改为 android:src="@drawable/animated_vector"
后,它也适用于 com.android.support:design:25.1.0
。
我不确定发生了什么,但至少现在它可以工作了。如果有人对此有更多详细信息,请告诉我。我以为我们应该使用 srcCompat
作为矢量绘图。
我不明白为什么我的 Animated Vector 不工作。我可以看到第一条路径,但我想作为第一条路径的补充的第二条路径没有显示。这是我的代码的样子:
<?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">
<aapt:attr name="android:drawable">
<vector
android:height="24dp"
android:width="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0" >
<path
android:name="v"
android:strokeColor="#000000"
android:strokeWidth="3"
android:pathData="M6,11 l3.5, 4 l0, 0" />
</vector>
</aapt:attr>
<target android:name="v" >
<aapt:attr name="android:animation">
<set>
<objectAnimator
android:duration="1000"
android:propertyName="pathData"
android:valueFrom="M6,11 l3.5, 4 l0, 0"
android:valueTo="M6,11 l3.5, 4 l8, -7"
android:valueType="pathType"/>
</set>
</aapt:attr>
</target>
</animated-vector>
因此,M6,11 l3.5, 4 l0, 0
显示在屏幕上而不是 M6,11 l3.5, 4 l8, -7
我尝试从 google 文档 here 的底部复制示例,但确实有效。如果我使用他们的代码告诉我我正确启动动画,我的文件动画正确。这是拼写错误还是我的路径数据有问题?
我在一个新项目中测试了我的可绘制对象,令我惊讶的是它运行良好。
我在我的第一个项目中使用 com.android.support:design:25.1.0
,结果降级为 com.android.support:design:24.2.0
使它起作用。
经过更多测试后,我发现将 ImageView
上的 app:srcCompat="@drawable/animated_vector"
更改为 android:src="@drawable/animated_vector"
后,它也适用于 com.android.support:design:25.1.0
。
我不确定发生了什么,但至少现在它可以工作了。如果有人对此有更多详细信息,请告诉我。我以为我们应该使用 srcCompat
作为矢量绘图。