Skip to content

Repository files navigation

Animation Android

  • Support APNG & Animated Webp & Gif & AVIF in Android
  • Efficient decoder
  • Support Drawable usage and glide library module
  • Support animation play control
  • Support still image
  • Low memory usage

Usages

Add dependency in 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}'
}

Notice Before Use!

Don't put APNG resources in your drawable or mipmap directory! During the process of release building of an Android app, the aapt tool will zip & modify the frame info of the APNG file, which will lead to an abnormal behavior when playing it. Thus, please put the APNG resources in raw or assets folder instead.

Use

// Load from asset fileAssetStreamLoaderassetLoader = newAssetStreamLoader(context, "wheel.png");
// Load form ResourceResourceStreamLoaderresourceLoader = newResourceStreamLoader(context, R.drawable.sample);
// Load from fileFileStreamLoaderfileLoader = newFileStreamLoader("/sdcard/Pictures/1.webp");
// Create APNG DrawableAPNGDrawableapngDrawable = newAPNGDrawable(assetLoader);
//Create Animated webp drawableWebPDrawablewebpDrawable = newWebPDrawable(assetLoader);
//Create Animated avif drawableAVIFDrawableavifDrawable = newAVIFDrawable(assetLoader);
// Auto playimageView.setImageDrawable(apngDrawable);
// Not needed.default controlled by contentapngDrawable.setLoopLimit(10);
// Implement Animatable2Compatdrawable.registerAnimationCallback(newAnimatable2Compat.AnimationCallback() {
@OverridepublicvoidonAnimationStart(Drawabledrawable) {
super.onAnimationStart(drawable);
}
});

Glide support

Add dependency in build.gradle

repositories {
...
mavenCentral()
}
dependencies {
implementation 'com.github.penfeizhou.android.animation:glide-plugin:${VERSION}'
}

Direct use

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);

Welcome to join the talk

image

Star History

Star History Chart

About

Android animation support for APNG & Animated WebP & Gif & Animated AVIF, High performance

Topics

Resources

Stars

666 stars

Watchers

15 watching

Forks

Releases

Packages

Used by

Contributors

Languages