Android 基本AnimatedVectorDrawable
示例
一个AnimatedVectorDrawable需要至少3个部分组成:
一个VectorDrawable将被操纵的
一个objectAnimator定义要更改的属性以及如何更改
将AnimatedVectorDrawable其连接本身objectAnimator的VectorDrawable创建动画
以下内容创建了一个三角形,将其颜色从黑色转换为红色。
的VectorDrawable,文件名:triangle_vector_drawable.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:name="triangle"
android:fillColor="@android:color/black"
android:pathData="M0,24 l12,-24 l12,24 z"/>
</vector>的objectAnimator,文件名:color_change_animator.xml
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="fillColor"
android:duration="2000"
android:repeatCount="infinite"
android:valueFrom="@android:color/black"
android:valueTo="@android:color/holo_red_light"/>的AnimatedVectorDrawable,文件名:triangle_animated_vector.xml
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/triangle_vector_drawable">
<target
android:animation="@animator/color_change_animator"
android:name="triangle"/>
</animated-vector>请注意,<target>指定android:name="triangle"与<path>中的匹配VectorDrawable。AVectorDrawable可以包含多个元素,并且该android:name属性用于定义要定位的元素。
结果:
热门推荐
1 泰迪狗狗如何训练
3 狗狗训练图
5 狗狗训练方法
6 训练狗狗不咬人
8 敏捷训练狗狗
10 训练狗狗吃饭
11 泰迪狗狗训练
12 狗狗从多大开始训练
13 狗狗训练学校费用
14 怎么去训练狗狗
15 狗狗训练狗狗
16 狗狗训练教程
17 训练狗狗装死
18 泰迪狗狗的训练方法