Glide centerCrop() 不适用于 CustomTarget

互联网 更新时间:2023-04-26 21:04:07

Slo*_*ing 5

由于某些未知的原因,当您使用CustomTarget<Bitmap>inside时会出现问题into()。如果你只是这样使用它:

ImageView imageView = findViewById(R.id.image);
Glide.with(this)
            .asBitmap()
            .load("lomsnesvet.ca/wp-content/uploads/sites/21/2019/08/Kitten-Blog-1600x2400.jpg")
            .centerCrop()
            .into(imageView);

这有效,并将图像显示为centerCrop(). 但是当你使用CustomTarget<Bitmap>它时会忽略该方法。你可以做的是:

ImageView imageView = findViewById(R.id.image);
Glide.with(this)
            .asBitmap()
            .load("lomsnesvet.ca/wp-content/uploads/sites/21/2019/08/Kitten-Blog-1600x2400.jpg")
            .centerCrop()
            .into(new CustomTarget<Bitmap>() {
                @Override
                public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                    imageView.setImageBitmap(resource);
                    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                }

                @Override
                public void onLoadCleared(@Nullable Drawable placeholder) {

                }
            });

然后你得到这个:

更多推荐

不适用于,Glide,centerCrop,CustomTarget

本文发布于:2023-04-26 21:04:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/hyzx/ec8495ab61aea68892c412dfbec6686c.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不适用于   Glide   centerCrop   CustomTarget

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 89742文章数
  • 23112阅读数
  • 0评论数