有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在Glide上显示gif

我想在recycler Adapter中的Glide error()上显示gif。 我该怎么做

我想在Glide中显示一张图片,当互联网断开连接时,我会显示Gif,但Glide Gif不会显示。 这是我的滑动代码,只是显示加载_回来。gif,未显示连接失败。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);

共 (1) 个答案

  1. # 1 楼答案

    来自This this问题

    构建。gradle(应用程序级)

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

    使用Glide.

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