项目
在 GitHub 查看
penfeizhou/APNG4Android
penfeizhou/APNG4Android has 669 GitHub stars and 91 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-15 22:32 UTC. Last push 2025-07-18.
实测星标增长
- 24小时
- 0
- 7天
- 正在收集历史
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
关于
Android animation support for APNG & Animated WebP & Gif & Animated AVIF, High performance
创作与媒体README-zh_CN.md
原文Android 动画播放库
- 支持常用动画格式APNG、Animated WebP、Gif、AVIF
- 解码实现高效,占用内存极低
- 支持按Resource、Assets、File等多种方式读取
- 提供Glide插件,可使用Glide直接加载
- 支持动画播放过程控制
- 支持静图展示
版本记录
使用说明
在build.gradle添加依赖
repositories {
mavenCentral()
}
Animated WebP
dependencies {
implementation 'com.github.penfeizhou.android.animation:awebp:${VERSION}'
}
APNG
dependencies {
implementation 'com.github.penfeizhou.android.animation:apng:${VERSION}'
}
Gif
dependencies {
implementation 'com.github.penfeizhou.android.animation:gif:${VERSION}'
}
AVIF
dependencies {
implementation 'com.github.penfeizhou.android.animation:avif:${VERSION}'
}
使用前请注意!
不要将APNG资源放置到drawable或者mipmap目录下! 在Android app release构建过程中, aapt工具会压缩修改APNG资源的帧信息, 会导致播放不正常. 因此请将APNG资源放置到工程内的raw或者assets目录内.
使用
// 从asset file中加载
AssetStreamLoader assetLoader = new AssetStreamLoader(context, "wheel.png");
// 从resource中加载
ResourceStreamLoader resourceLoader = new ResourceStreamLoader(context, R.drawable.sample);
// 从file中加载
FileStreamLoader fileLoader = new FileStreamLoader("/sdcard/Pictures/1.webp");
// 创建APNG Drawable
APNGDrawable apngDrawable = new APNGDrawable(assetLoader);
//创建 Animated webp drawable
WebPDrawable webpDrawable = new WebPDrawable(assetLoader);
//自动播放
imageView.setImageDrawable(apngDrawable);
//可覆盖动画中设置的播放次数
apngDrawable.setLoopLimit(10);
// 实现Animatable2Compat接口
drawable.registerAnimationCallback(new Animatable2Compat.AnimationCallback() {
@Override
public void onAnimationStart(Drawable drawable) {
super.onAnimationStart(drawable);
}
});
Glide插件
build.gradle中添加依赖
repositories {
...
mavenCentral()
}
dependencies {
implementation 'com.github.penfeizhou.android.animation:glide-plugin:${VERSION}'
}
使用Glide加载图片
Glide.with(imageView).load("https://misc.aotu.io/ONE-SUNDAY/SteamEngine.png").into(imageView);
Glide.with(imageView).load("https://isparta.github.io/compare-webp/image/gif_webp/webp/2.webp").into(imageView);