首先在项目的build.gradle中加入allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
然后在app下的build.gradle添加依赖,这里的版本号可以去官网查一下(http://svga.io/index.html)compile'com.github.yyued:SVGAPlayer-Android:2.0.3'
添加混淆-keep class com.squareup.wire.** { *; }
-keep class com.opensource.svgaplayer.proto.** { *; }
然后将准备好的.svga文件放在assets下
下面是使用方法:
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:clearsAfterStop="true" />private SVGAImageViewmSVGAImageView;
mSVGAImageView = findViewById(R.id.imageView);
SVGAParser parser =new SVGAParser(PreviewActivity.this);
mSVGAImageView.setLoops(1);//设置动画执行一次,如果不设置就会一直循环播放动画,根据需求设置
par