从 URL 加载 GIF
Load GIF From URL
我试过从 URL 中获取 this GIF,如下所示:
Glide.with(context)
.load("http://artfcity.com/wp-content/uploads/2017/07/tumblr_osmx1ogeOD1r2geqjo1_540.gif")
.into(new GlideDrawableImageViewTarget(imageViewBaby) {
@Override
public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) {
super.onResourceReady(drawable, anim);
imageViewBaby.setImageDrawable(drawable);
imageViewBaby.invalidate();
imageViewBaby.requestLayout();
}
});
但是 GIF 不会移动或启动。它就像一个图像!如何解决这个问题?
试试这个
添加依赖
implementation 'com.github.bumptech.glide:glide:4.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
Gif 加载
Glide.with(this)
.load("http://artfcity.com/wp-
content/uploads/2017/07/tumblr_osmx1ogeOD1r2geqjo1_540.gif")
.apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
.into(imageView);
由于android不支持gif文件,您可以使用webview显示gif文件。
请使用 .asGif()
加载 gif 图片到您的 ImageView
:
Glide.with(context)
.load(gifUrl)
.asGif()
.diskCacheStrategy(DiskCacheStrategy.SOURCE).override(200, 200)
.into(((GifViewHolder) holder).gifImageView);
我试过从 URL 中获取 this GIF,如下所示:
Glide.with(context)
.load("http://artfcity.com/wp-content/uploads/2017/07/tumblr_osmx1ogeOD1r2geqjo1_540.gif")
.into(new GlideDrawableImageViewTarget(imageViewBaby) {
@Override
public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) {
super.onResourceReady(drawable, anim);
imageViewBaby.setImageDrawable(drawable);
imageViewBaby.invalidate();
imageViewBaby.requestLayout();
}
});
但是 GIF 不会移动或启动。它就像一个图像!如何解决这个问题?
试试这个
添加依赖
implementation 'com.github.bumptech.glide:glide:4.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
Gif 加载
Glide.with(this)
.load("http://artfcity.com/wp-
content/uploads/2017/07/tumblr_osmx1ogeOD1r2geqjo1_540.gif")
.apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
.into(imageView);
由于android不支持gif文件,您可以使用webview显示gif文件。
请使用 .asGif()
加载 gif 图片到您的 ImageView
:
Glide.with(context)
.load(gifUrl)
.asGif()
.diskCacheStrategy(DiskCacheStrategy.SOURCE).override(200, 200)
.into(((GifViewHolder) holder).gifImageView);