0

I need to load a Gif from the drwable folder in my image view. How can i show this in glide 4.11.0 version?

Also, note asGif method can't able to resolve.

Glide
   .with(this)
   .load(R.drawable.run).asGif()
   .into(mGifImage);
sejn
  • 2,040
  • 6
  • 28
  • 82
  • 1
    this https://stackoverflow.com/q/31082330/4936904? – Pavneet_Singh Dec 17 '20 at 05:46
  • @Pavneet_Singh Can yu let me know if I add the gif in drawable file and straightly shown in UI works or not? Or shall i need to chnage the gif to any uri – sejn Dec 17 '20 at 05:50
  • I can't able to see the gif ImageView imageView = (ImageView) v.findViewById(R.id.gif); Glide.with(this).asGif().load(R.raw.steam4).into(imageView); code : – sejn Dec 17 '20 at 06:16

2 Answers2

1

Worked using the below

Glide.with(itemView.getContext())
    .asGif()
    .load(thumbPath)                             
    .placeholder(ResourcesCompat.getDrawable(context.getResources(), 
                     R.drawable.image_loading_placeholder, null))
    .centerCrop()
    .into(new ImageViewTarget<GifDrawable>(imageView) {
         @Override
         protected void setResource(@Nullable GifDrawable resource) {
             imageView.setImageDrawable(resource);
         }
     });
sejn
  • 2,040
  • 6
  • 28
  • 82
  • this worked for me on 'com.github.bumptech.glide:glide:4.12.0' I think it's because of the ImageViewTarget part. Because I tried using .asGif() on a different version that was using BitmapImageViewTarget and it didn't work – Anna Harrison Mar 31 '22 at 18:08
0
Glide
   .with(this)
   .asGif()
   .load(R.drawable.run).asGif()
   .into(mGifImage);

if asGIF() didn't work then

use this library GIFPLAYER