安卓用shape画圆角矩形边框

您所在的位置:网站首页 qq三国安卓框框效果图 安卓用shape画圆角矩形边框

安卓用shape画圆角矩形边框

2024-05-18 20:10| 来源: 网络整理| 查看: 265

效果图: 代码: 一、xml方式 代码: shape_rec_blue.xml 圆角矩形边框 圆角矩形背景 使用 二、kotlin方式 代码 圆角矩形边框 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() 完整源代码

https://gitee.com/hspbc/shapeDemos.git



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3