方法1:Outline
实现方法:
1) 要设置圆角的View.setClipToOutline(true)
2)要设置圆角的View.setOutlineProvider(ViewOutlineProvider provider)
ViewOutlineProvider 只有1个抽象方法,通过Outline.setRoundRect设置圆角:
方法特点:
2)对4个角同时设置,不能单独设置单个角
方法2:CardView
实现方法:
方法特点:
方法3:自定义Drawable
实现方法:
方法特点:
方法4:GradientDrawable和RoundedBitmapDrawable
实现方法:GradientDrawable
方法特点:GradientDrawable
实现方法:RoundedBitmapDrawable
方法特点:RoundedBitmapDrawable
方法5:3方库,本例用Glide
实现方法:
方法特点:
不同方法效果对比:
代码地址:
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。