Adnroid 安卓Glide加载圆角

写好了一个工具类
要在自己项目中build.gradle加入以下内容(导入Glide)
在这里插入图片描述

implementation('com.github.bumptech.glide:glide:4.7.1') {
        exclude group: "com.android.support"
}

可以自己设置圆角度数,也可以自动设置,如第5行,我写了20

public class GlideTool {

    @SuppressLint("CheckResult")
    public static void GlideRadius(Context context, String url, ImageView imageView) {
        //设置图片圆角角度
        RoundedCorners roundedCorners = new RoundedCorners(20);
        RequestOptions options = RequestOptions.bitmapTransform(roundedCorners).override(0, 0);
        Glide.with(context).load(url).apply(options).into(imageView);
    }

    @SuppressLint("CheckResult")
    public static void GlideRadius(Context context, String url, ImageView imageView, int radius) {
        //设置图片圆角角度
        RoundedCorners roundedCorners = new RoundedCorners(radius);
        RequestOptions options = RequestOptions.bitmapTransform(roundedCorners).override(0, 0);
        Glide.with(context).load(url).apply(options).into(imageView);
    }


}

其运行效果如下:
在这里插入图片描述

发布了99 篇原创文章 · 获赞 1020 · 访问量 76万+

猜你喜欢

转载自blog.csdn.net/qq_40881680/article/details/102715421