先看效果#
image.png代码实现:
val colors = intArrayOf(
Color.parseColor("#D3BEFF"),
Color.parseColor("#9BABFD"),
Color.parseColor("#5C97FB")
)
val drawable = GradientDrawable()
drawable.gradientType = GradientDrawable.RECTANGLE
drawable.cornerRadius = 10f
drawable.orientation = GradientDrawable.Orientation.LEFT_RIGHT
drawable.colors = waterColors
topView.background = drawable
GradientDrawable
想要其它设置可以自行查找api进行设置
网友评论