您可以将 Glide 用于 GIF..它是更好的库。
Glide 与 Picasso 非常相似,但比 Picasso 快得多。Glide 比 Picasso 消耗更少的内存。
Glide 有但 Picasso 没有的功能 将 GIF 动画加载到简单的 ImageView 可能是 Glide 最有趣的功能。是的,你不能用毕加索做到这一点。
一些重要的链接-
1. https://github.com/bumptech/glide
2. http://inthecheesefactory.com/blog/get-to-know-glide-recommended-by-google/en
您还可以使用 Ion库来加载 gif。
参考这个链接点击这里
它的 Gradle 依赖项:-
dependencies {
...
compile 'com.android.support:support-v4:23.1.0'
compile 'com.koushikdutta.ion:ion:2.+'
}
从drawable加载gif如下: -
ImageView imgView=(ImageView) view.findViewById(R.id.imageView);
Ion.with(imgView)
.error(R.drawable.error_image)
.animateGif(AnimateGifMode.ANIMATE)
.load("android.resource://" + PackageName + "/" + R.drawable.loadingbh)
.withBitmapInfo();
并从URL加载图像,例如:-
Ion.with(imgView)
.error(R.drawable.error_image)
.animateGif(AnimateGifMode.ANIMATE)
.load("https://www.beginnersheap.com/wp-content/uploads/2016/08/loading-BH.gif") ///LOAD YOUR URL GIF
.withBitmapInfo();