android - 从 URL 加载 GIF

标签 android android-glide

我试图得到 this GIF来自这样的 URL:

 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'

动图加载

    Glide.with(this)
      .load("http://artfcity.com/wp-
      content/uploads/2017/07/tumblr_osmx1ogeOD1r2geqjo1_540.gif")
            .apply(RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.NONE))
            .into(imageView);

查看此 https://github.com/bumptech/glide/issues/2471

关于android - 从 URL 加载 GIF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48013012/

相关文章:

Android Studio IDE 显示未解析的引用/忽略导入,而构建正常

javascript - 如何缩放 webview 使其文本内容不会换行?

java - 如何使用 glide 库使用 SQLite 在 gridview 中显示图像?

android - alertdialog 从 xml 中读取以及如何将文本放入 textview

android - 错误 : A factory has already been set on this LayoutInflater (change background color of menu options)

android - 我什么时候应该关闭对话框?

android - 将 Glide 与 GoogleMap.InfoWindowAdapter 结合使用

java - 无法运行我的调试应用程序,因为出现 Glide 错误

java - 无法在Android中下载图像

android - 错误:In <declare-styleable> FontFamilyFont, 找不到属性android :font after Glide 4. 4 升级