本文介绍了如何使用 Glide 库对图像进行四舍五入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

那么,有人知道如何使用 Glide 显示带圆角的图像吗?我正在使用 Glide 加载图像,但我不知道如何将舍入参数传递给该库.

So, anybody know how to display an image with rounded corners with Glide?I am loading an image with Glide, but I don't know how to pass rounded params to this library.

我需要像以下示例一样显示图像:

I need display image like following example:

推荐答案

Glide V4:

    Glide.with(context)
        .load(url)
        .circleCrop()
        .into(imageView);

Glide V3:

您可以将 RoundedBitmapDrawable 用于带有 Glide 的圆形图像.不需要自定义 ImageView.

You can use RoundedBitmapDrawable for circular images with Glide. No custom ImageView is required.

 Glide.with(context).load(url).asBitmap().centerCrop().into(new BitmapImageViewTarget(imageView) {
        @Override
        protected void setResource(Bitmap resource) {
            RoundedBitmapDrawable circularBitmapDrawable =
                    RoundedBitmapDrawableFactory.create(context.getResources(), resource);
            circularBitmapDrawable.setCircular(true);
            imageView.setImageDrawable(circularBitmapDrawable);
        }
    });

这篇关于如何使用 Glide 库对图像进行四舍五入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 13:18
查看更多