偶然間 看到一個類庫 關于svg 動畫,可以下載demo 運行看源碼哦
GitHub最詳細的SvgDemo:
https://github.com/jrummyapps/AnimatedSvgView首先 大家還是要知道 該去哪里下載svg圖 這點阿里做的很
矢量圖片庫---
http://iconfont.cn/collections
阿里矢量圖形庫---
http://iconfont.cn/plus/collections/detail?cid=3057
那接下來 我們 說一下使用的步驟
- 下載一個svg文件.png
- 
-
這就是生成的xml文件.png
根據上圖的方式可以獲得drawable類型的xml文件,里面有path,color,height,weigh
*接下來要說的就是正兒八經的使用方法了you
<com.jrummyapps.android.widget.AnimatedSvgView
android:id="@+id/animated_svg_view"
android:layout_width="180dp"
android:layout_height="180dp"
android:layout_gravity="center"
android:layout_marginBottom="25dp"
app:animatedSvgFillColors="@array/didi_glyph_colors"
app:animatedSvgFillStart="1200"
app:animatedSvgFillTime="1000"
app:animatedSvgGlyphStrings="@array/didi_glyph_strings"
app:animatedSvgImageSizeX="1792"
app:animatedSvgImageSizeY="1792"
app:animatedSvgTraceMarkerLength="50"
app:animatedSvgTraceTime="2000"
app:animatedSvgTraceTimePerGlyph="1000" />
我們會看到這比較顯眼的array引用 大家有會想array文件是哪里冒出來的呢哈哈 自己寫的唄
- 這里的string array 里的item 其實對應的就是生成xml文件里的pathdata
同樣 integer array 對應的就是fillcolor 說到這里 真相大白了。至于其他的屬性 我再繼續研究一下 安嘍
3F5EB311-4BC9-495D-87D7-49981284C474.png