Reputation: 3240
I want to load a gif into an imageview, it is displayed but doesn't start playing. I use this code:
Glide.with(context)
.load("https://media.giphy.com/media/7rj2ZgttvgomY/giphy.gif")
.into(imageView)
I've also tried adding .asGif()
but in that case image is not displayed at all. I'm using glide 3.8.0
Upvotes: 4
Views: 5543
Reputation: 3348
In my case I had set the imageview dimensions to match_parent and specifying it in dp did it for me.
Not sure why exactly match_parent doesn't work in a dialog, playing GIFs, probably something to do with the scaling, if this is the case then using scaleType:fitXY should work too
Upvotes: 2
Reputation: 2985
There is nothing wrong with your code. You could check if you have Internet
permission.
<uses-permission android:name="android.permission.INTERNET" />
Your internet speed might be slow and Glide
might be taking too much time to load so by that time you could add a placeholder image using :
.placeholder(android.R.color.holo_green_dark)
Or you could add Listner
to the Request
using
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
})
And see what is the Exception
.
Upvotes: 0
Reputation: 1791
You can refer to : https://github.com/bumptech/glide/issues/1059
If you don't find it, you can change the lastest version of Gline
repositories {
mavenCentral()
maven { url 'https://maven.google.com' }
}
dependencies {
compile 'com.github.bumptech.glide:glide:4.2.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
}
I hope you can find solution.
Upvotes: 0
Reputation: 10126
Change your gif your to https://i.giphy.com/media/7rj2ZgttvgomY/giphy.webp
Glide.with(context)
.load("https://i.giphy.com/media/7rj2ZgttvgomY/giphy.webp")
.asGif().into(imageView);
Also you can try GIFView
Upvotes: 0
Reputation: 4087
You can also try
Glide
.with(context)
.load(gifUrl)
.asGif()
.error(R.drawable.full_cake)
.diskCacheStrategy(DiskCacheStrategy.SOURCE)`
.into(imageViewGif);
Upvotes: 0
Reputation: 6622
try this.
Glide.with(context)
.load(imageUrl)
.asGif()
.placeholder(R.drawable.loading2)
.crossFade()
.into(imageView);
Upvotes: 1