Android 资源目录drawable下常常可以看到如下类似内容的xml,使用vector、path标签构建矢量图
ic_wifi_signal_0.xml
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="26dp"
android:height="24dp"
android:viewportWidth="26"
android:viewportHeight="24">
<path
android:fillAlpha="0.3"
android:fillColor="#FFFFFF"
android:pathData="M13.0,22.0L25.6,6.5C25.1,6.1 20.3,2.1 13.0,2.1S0.9,6.1 0.4,6.5L13.0,22.0L13.0,22.0L13.0,22.0L13.0,22.0L13.0,22.0z"/>
</vector>
效果图:
其中的path标签中的pathData使用了W3C定义的SVG 意为可缩放矢量图形(Scalable Vector Graphics)
pathData语法定义见:
SVG path
https://www.w3.org/TR/SVG11/paths.html#PathData
在Android Studio中可以使用Vector Asset来使用Google提供的矢量图或导入SVG和PSD格式的矢量文件
其他参考资料:
Vector drawables overview
https://developer.android.google.cn/guide/topics/graphics/vector-drawable-resources?hl=en
Add multi-density vector graphics
https://developer.android.google.cn/studio/write/vector-asset-studio?hl=en#importing
SVG 的 PathData 在 Android 中的使用
https://blog.csdn.net/zwlove5280/article/details/73196543