Adding GIF image in an ImageView in android

ยท ยท 207 words ยท 1 minute read

use android-gif-drawable library ๐Ÿ”—

add the following dependency to build.gradle file of your project.

dependencies {
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'

Use the view in XML file like this.


For more customization and code, see the docs here .

use VideoView on Android ๐Ÿ”—

You can use VideoView to show the GIF image. But the library is more efficient and smooth.

use ImageView on Android ๐Ÿ”—

Use ImageView and Split the GIF file into several images and then apply animation to it. It is complicated and not worth it because the library is more efficient and elegant.

use Glide library ๐Ÿ”—

add the dependency to build.gradle like this.

repositories {

dependencies {
  implementation 'com.github.bumptech.glide:glide:4.8.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'

Then in activity or fragment use this code.

ImageView imageView = findViewById(;

If you want to pull the image from the Internet, use this code snippet.


But if you want to use a local image from raw folder in your Android app, use this code snippet.


If you are already using Glide, use the code above. But if you are not using Glide in your app, just use the first library because it is lightweight and efficient.