随着互联网技术的不断进步,Android的Vector图像的时代已经到来. 在Google的最新支持库v23.2中, AppCompat类已经使用Vector图像, 使得AAR包减少9%, 大约70KB, 惠及所有高版本的应用. 当然我们也可以使用Vector, 瘦身应用. Vector图像是SVG格式在Android的表现形式. SVG图像适应屏幕, 图片较小, 还有很多优点, 参考.
关于Vectors的分析, 主要分为两节:
(1) 使用SVG图像瘦身应用, 参考.
(2) 绘制优美的路径动画, 参考.
本文是第二节, 关于Vector动画.
SDK Manager提示支持库更新
使用Vector动画主要有三个部分: Vector图像, 路径动画, Animated-Vector图像.
本文源码的Github下载地址.
动画
1. Vector图像
SVG格式的图片, 转换为Vector图像资源, 可以使用AS2.0的转换工具, 也可以是在线转换工具, 参考. 图像需要路径(path)样式, 便于绘制, 如
<vector xmlns:android="http://www.easck.com/apk/res/android" android:width="256dp" android:height="256dp" android:viewportHeight="70" android:viewportWidth="70"> <path android:name="heart1" android:pathData="..." android:strokeColor="#E91E63" android:strokeWidth="1"/> <path android:name="heart2" android:pathData="..." android:strokeColor="#E91E63" android:strokeWidth="1"/> </vector>













