使用 Glide 显示 GIF 文件(图像加载和缓存库) [英] Show GIF file with Glide (image loading and caching library)
本文介绍了使用 Glide 显示 GIF 文件(图像加载和缓存库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在图像视图中将 GIF 图像显示为加载占位符 - 使用 Glide 库:
I try to show a GIF image as loading placeholder in image view - with Glide Library:
Glide.with(context)
.load(ImageUrl())
.placeholder(R.drawable.loading2)
.asGif()
.crossFade()
.into(image);
我尝试显示此文件
loading2.gif
loading2.gif
但是得到这个错误:
错误:(54, 86) 错误:找不到符号方法 asGif()
Error:(54, 86) error: cannot find symbol method asGif()
如何在 imageView 中使用 Glide 显示 GIF 文件?
How can I show GIF file with Glide in a imageView?
推荐答案
以上答案对我不起作用.下面的代码有效.
The above answer didn't work for me. The below code works.
ImageView imageView = (ImageView) findViewById(R.id.imageView);
GlideDrawableImageViewTarget imageViewTarget = new GlideDrawableImageViewTarget(imageView);
Glide.with(this).load(R.raw.sample_gif).into(imageViewTarget);
这篇关于使用 Glide 显示 GIF 文件(图像加载和缓存库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文