Pag动画框架作为一个第三方框架,它的优缺点与Lottie是相似,此处不过多赘述。如果你们的项目中打算用了,肯定是经过了一定的调研的。Pag动画框架分几个版本,有免费的有收费的。我们目前用的社区免费版,只用来展示Pag动画。高级的版本可以播放视频、声音等,酌情选取。
github文档:
https://github.com/Tencent/libpag
引入依赖
// pag库的库 
implementation 'com.tencent.tav:libpag:4.2.100' 
/// pag的依赖库 必须添加 
implementation "androidx.exifinterface:exifinterface:1.3.3"混淆配置
-keep class org.libpag.** {*;} 
-keep class androidx.exifinterface.** {*;}使用PagView
xml
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent" 
android:orientation="vertical"> <org.libpag.PAGView android:id="@+id/pag" android:layout_width="match_parent" android:layout_height="match_parent"/> 
</LinearLayout>assets中添加文件

Java/Kotlin代码
// 加载Pag文件并开始动画 
findViewById<PAGView>(R.id.pag).apply { 
// 把0.pag放在 assets目录下 composition = PAGFile.Load(assets, "pag/0.pag") 
// 无限循环 
setRepeatCount(-1) 
play() 
}