效果图: 
                
                
        - 代码: shape_rec_blue.xml
- 圆角矩形边框
    
    
- 圆角矩形背景
    
    
- 使用
    
        
    
- 代码
- 圆角矩形边框
private fun getRoundRectStroke() = GradientDrawable().also {
    it.shape = GradientDrawable.RECTANGLE
    it.cornerRadius = 10f //圆角度数
    val strokeWidth = 4 // 边框宽度
    val strokeColor = Color.parseColor("#418DF9") //边框颜色
    it.setStroke(strokeWidth, strokeColor)
}
- 圆角矩形背景
private fun getRoundRect() = GradientDrawable().also {
    it.shape = GradientDrawable.RECTANGLE
    it.cornerRadius = 10f
    it.setColor(Color.parseColor("#418DF9"))
}
- 使用方法
view.background = getRoundRect()
- 安卓用shape画圆
安卓开发技术分享: https://www.jianshu.com/p/442339952f26 

 
                 
    