如何在Glide上显示gif [英] How to show gif on Glide

查看:138
本文介绍了如何在Glide上显示gif的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在回收适配器中显示Glide error()的gif. 我该怎么办?

I want to show gif on Glide error() in recycler Adapter. how should I do that?

我想在Glide中显示图片,并且当互联网断开连接时,我将显示一个Gif,但Glide Gif将不会显示. 这是我的滑行代码,仅显示loading_back.gif而未显示connection_fail.gif.

I want to show a picture in Glide, and when the internet will be disconnected, I'll show a Gif, but Glide Gif will not show. here is my glide code that just shows loading_back.gif and didn't show connection_fail.gif .

 RequestOptions options = new RequestOptions()
            .centerCrop()
            .placeholder(R.drawable.static_place_holder)
            .error(R.drawable.connection_fail)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .priority(Priority.HIGH);

    Glide.with(context)
            .load(items.get(pos).getLinks())
            .apply(options)
            .thumbnail(Glide.with(context).load(R.drawable.loading_back))
            .thumbnail(Glide.with(context).load(R.drawable.connection_fail))
            .into(holder.imageView);

推荐答案

来自这个问题.

build.gradle(应用级)

dependencies {
  implementation 'com.github.bumptech.glide:glide:4.8.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
}

使用 Glide.

Use of Glide.

Glide.with(context)
    .load(imgUrl)
    .asGif()
    .placeholder(R.drawable.img)
    .crossFade()
    .into(imageView);

这篇关于如何在Glide上显示gif的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆