适用于 Android 的动画 SVG 绘图
适用于 Android 的动画 SVG 绘图
获取 SVG 路径数据并将其添加到字符串数组中:
…将每条路径的颜色添加到整型数组中:
<color name="google_red">#EA4335</color>
<color name="google_yellow">#FBBC05</color>
<color name="google_blue">#4285F4</color>
<color name="google_green">#34A853</color>
<integer-array name="google_glyph_colors">
<item>@android:color/white</item>
<item>@color/google_red</item>
<item>@color/google_yellow</item>
<item>@color/google_blue</item>
<item>@color/google_green</item>
</integer-array>将视图添加到布局中:
<com.jaredrummler.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/google_glyph_colors"
app:animatedSvgGlyphStrings="@array/google_glyph_strings"
app:animatedSvgFillStart="1200"
app:animatedSvgFillTime="1000"
app:animatedSvgImageSizeX="400"
app:animatedSvgImageSizeY="400"
app:animatedSvgTraceTime="2000"
app:animatedSvgTraceTimePerGlyph="1000"/>播放动画:
AnimatedSvgView svgView = (AnimatedSvgView) findViewById(R.id.animated_svg_view);
svgView.start();您还可以动态设置 SVG 字形和颜色(请参阅 示例)。
下载 最新的 AAR 或通过 Gradle 进行下载:
compile 'com.jaredrummler:animated-svg-view:1.0.6'或 Maven:
<dependency>
<groupId>com.jaredrummler</groupId>
<artifactId>animated-svg-view</artifactId>
<version>1.0.6</version>
<type>aar</type>
</dependency>AnimatedMuzeiLogoView 由 Roman Nurik 创建 oak-animatedsvgview 由 WillowTree, Inc. 提供
暂无开放 Issues,或尚未同步最近议题。