Skip to content
Svg动画播放
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app
gradle/wrapper
svglibary
.gitignore
README.md
build.gradle
gradle.properties
gradlew
gradlew.bat
settings.gradle

README.md

SvgAnim

PNG转SVG推荐 vmde工具

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

dependencies {
	compile 'com.github.pencilso:SvgAnim:v1.0.2'
}

XML文件布局

 <com.jaredrummler.android.widget.AnimatedSvgView
    android:id="@+id/animated_svg_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginBottom="25dp"
    app:animatedSvgFillStart="1200"
    app:animatedSvgFillTime="1000"
    app:animatedSvgImageSizeX="400"
    app:animatedSvgImageSizeY="400"
    app:animatedSvgTraceTime="2000"
    app:animatedSvgTraceTimePerGlyph="1000" />

初始化配置

 //路径为svg图片的路径
 SvgEntity config = SvgUtils.config(getAssets().open("20171110143319.svg"), SvgConfig.GLYPHS_RANDOM);
 //初始化 方法
 //SvgUtils.config(String path);
 //SvgUtils.config(InputStream path);

启动动画

	animatedSvgView.setGlyphStrings(config.getGlyphs());
        animatedSvgView.setFillColors(config.getColors());
        animatedSvgView.setViewportSize(config.getWidth(), config.getWidth());
        animatedSvgView.setTraceResidueColor(0x32000000);
        animatedSvgView.setTraceColors(config.getColors());
        animatedSvgView.rebuildGlyphData();
        animatedSvgView.start();

Thanks

AnimatedSvgView

效果预览

You can’t perform that action at this time.