正如问题中提到的,我正在尝试为手机图标做矢量可绘制动画。我的要求是显示手机动画,如手机图标是移动的,这就是它我尝试了所有的建议,从不同的网站,仍然动画是不起作用的,我尝试了这从过去两天仍然没有发生。
以下文件是我的代码,如果有任何问题,请给我建议。
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:name="phone2"
android:pathData="M 6.62 10.79 L 6.62 10.79 C 7.353 10.057 8.087 9.323 8.82 8.59 C 9.1 8.31 9.18 7.92 9.07 7.57 C 8.7 6.45 8.5 5.25 8.5 4 C 8.5 3.725 8.387 3.475 8.206 3.294 C 8.025 3.112 7.775 3 7.5 3 C 6.333 3 5.167 3 4 3 C 3.45 3 3 3.45 3 4 C 3 6.348 3.476 8.584 4.336 10.618 C 5.196 12.652 6.441 14.483 7.979 16.021 C 9.517 17.559 11.348 18.804 13.382 19.664 C 15.416 20.524 17.652 21 20 21 C 20.55 21 21 20.55 21 20 C 21 18.837 21 17.673 21 16.51 C 21 15.96 20.55 15.51 20 15.51 C 18.76 15.51 17.55 15.31 16.43 14.94 C 16.08 14.82 15.68 14.91 15.41 15.18 C 14.677 15.913 13.943 16.647 13.21 17.38 C 12.267 16.897 11.38 16.318 10.564 15.656 C 9.747 14.994 9.001 14.249 8.34 13.434 C 7.678 12.619 7.1 11.733 6.62 10.79"
android:fillColor="#000"
android:strokeWidth="1"/>
这是我的图标手机矢量文件。
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:drawable="@drawable/phone2_icon"
tools:targetApi="lollipop">
<target
android:animation="@animator/animation_rotation"
android:name="animation"/>
</animated-vector>
这是一个动画矢量文件。
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="6000"
android:propertyName="rotation"
android:valueFrom="0"
android:valueTo="180"
android:valueType="floatType"/>
</set>
这是我的动画文件,放在动画文件夹中。
如果有人知道什么,请帮助我第一次使用矢量绘图。
上面的图像是手机图标,我想它只是从180旋转到背部normal.Like,它将显示移动的动画。
发布于 2018-04-01 16:25:46
在AnimatedVectorDrawable文件中,您必须在“android:name=”下为目标指定"phone2“。还针对‘android:drawable=’...‘请给出文件名。如果"drawable“文件夹中的VectorDrawable文件的名称为"my_vector”,而" animator“文件夹中的动画制作文件的名称为"animation_rotation”,则AnimatedVectorDrawable文件应如下所示:
<animated-vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:drawable="@drawable/my_vector"
tools:targetApi="lollipop">
<target
android:animation="@animator/animation_rotation"
android:name="phone2"/>
</animated-vector>
https://stackoverflow.com/questions/47152306
复制相似问题