In API 28 AnimatedImageDrawable
was introduced for displaying gif images:
https://developer.android.com/reference/android/graphics/drawable/AnimatedImageDrawable.html
Drawable for drawing animated images (like GIF).
The problem is that they don't told anything about how to use it with AppCompat-v7
or Support-v4
libraries for retrocompatibility before API 28.
Does anyone know if is possible to use it before API 28 for displaying GIF images?
Short answer: No, you can't use AnimatedImageDrawable
below API 28 and there is no compat version of the class.
For your problem you have different options based on your situation:
Picasso
or Glide
, they both handle GIF images automatically and you can use them in place of AnimatedImageDrawable (I discourage you to add those big libraries just to handle GIF if you don't need the other features they provide).WebView
embedding the image in an HTML and then loading the HTML page inside the WebViewFor both options 1 and 2 you can find plenty of examples online. Some of them are in this thread: