Load GIF From URL

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-04 05:59:30

问题


I tried to get this GIF from a URL like this:

 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();
                    }
                });

But the GIF will not move or start. It's just like an image! How to solve this issue?


回答1:


Try this

Add dependency

  implementation 'com.github.bumptech.glide:glide:4.4.0'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'

Gif Loading

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

See this https://github.com/bumptech/glide/issues/2471




回答2:


As android doesnot support gif files, you can use webview to display the gif file.




回答3:


Please use .asGif() to load gif images inside your ImageView:

Glide.with(context)
            .load(gifUrl)
            .asGif()
            .diskCacheStrategy(DiskCacheStrategy.SOURCE).override(200, 200)
            .into(((GifViewHolder) holder).gifImageView);


来源:https://stackoverflow.com/questions/48013012/load-gif-from-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!