其他分享
首页 > 其他分享> > 我添加RequestListener时,Glide版本4.7.1无法将Gif加载到ImageView

我添加RequestListener时,Glide版本4.7.1无法将Gif加载到ImageView

作者:互联网

当我尝试从gif网址加载到ImageView时,我通过RequestListener添加了更多条件,但没有成功|

滑行版本:4.7.1
当我编码时,它起作用了:
Glide.with(context).asGif().load(gifModel.url).into(ivGif);

完全加载gif后,我想要ivPreGif

我添加了更多竞争条件,但是我没有工作

Glide.with(context)
                                .asGif()
                                .load(gifModel.url)
                                .listener(new RequestListener<GifDrawable>() {
                                    @Override
                                    public boolean onl oadFailed(@Nullable GlideException e, Object model, Target<GifDrawable> target, boolean isFirstResource) {
                                        return false;
                                    }
                                    @Override
                                    public boolean onResourceReady(GifDrawable resource, Object model, Target<GifDrawable> target, DataSource dataSource, boolean isFirstResource) {
                                        ivPreGif.setVisibility(View.GONE);
                                        ivGif.setVisibility(View.VISIBLE);
                                        return false;
                                    }
                                })
                                .into(ivGif);

解决方法:

尝试这个..

加载方法提供您的gif网址.

        Glide.with(this).load(R.drawable.user).into(imageView);

  Glide.with(this).load(R.drawable.user)
            .listener(new RequestListener<Drawable>() {
                @Override
                public boolean onl oadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                    return false;
                }

                @Override
                public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                     ivPreGif.setVisibility(View.GONE);
                    return false;
                }
            })
            .into(imageView);

标签:android-glide,gif,android
来源: https://codeday.me/bug/20191109/2011044.html