Skip to content

Latest commit

 

History

History

android-drawable

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

android-drawable

Maven Central

An implementation of an Android Drawable, using the decoder, as a simple way to display a gif in an Android app.

Setup

android-drawable is available on mavenCentral()

Add it to your dependencies with implementation "app.redwarp.gif:android-drawable:x.y.z"

In code, create a GifDrawable from any InputStream. GifDrawable implements Animatable2Compat , a user needs to call start() to start the animation.

// Example: with a gif included in your app as an asset
val inputStream = context.assets.open("some_animated.gif")

val drawable:GifDrawable = GifDrawable.from(inputStream)
drawable.start()

imageView.setImageDrawable(drawable)

Dependencies

This library depends on:

Alternatives

If you target Android 28, AnimatedImageDrawable is good and efficient. Below 28, it's not crystal clear what should be used.

Coil and Glide both bake their own version of a Gif decoder.

  • The Coil version relies on the Movie class and is quite expensive in term of memory and CPU usage. See MovieDrawable.
  • The Glide version is decent, see StandardGifDecoder.