How to round an image with Glide library?

前端 未结 22 1777
悲哀的现实
悲哀的现实 2020-11-28 00:46

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.

22条回答
  •  醉梦人生
    2020-11-28 01:09

    With glide library you can use this code:

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

提交回复
热议问题