如何使用Glide库对图像进行取整? [英] How to round an image with Glide library?

查看:132
本文介绍了如何使用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库对图像进行取整?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆