唯客微博客

专注于计算机,嵌入式领域的技术

0%

Modifier 边框(Border)

Modifier 边框(Border)

1
2
3
fun Modifier.border(border: BorderStroke, shape: Shape)
fun Modifier.border(width: Dp, color: Color, shape: Shape)
fun Modifier.border(width: Dp, brush: Brush, shape: Shape)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Column {
Text(
"Text with square border",
modifier = Modifier
.border(4.dp, Color.Magenta,
shape = CutCornerShape(8.dp))
.padding(10.dp)
)

Text(
"Text with gradient border",
modifier = Modifier
.border(
border = BorderStroke(2.dp, Color.Blue),
shape = CutCornerShape(8.dp)
)
.padding(10.dp)
)

val gradientBrush = Brush.horizontalGradient(
colors = listOf(Color.Red, Color.Blue, Color.Green),
startX = 0.0f,
endX = 500.0f,
tileMode = TileMode.Repeated
)

Text(
"Text with gradient border",
modifier = Modifier
.border(width = 2.dp, brush = gradientBrush, shape = CircleShape)
.padding(10.dp)
)
}
-------------本文结束感谢您的阅读-------------

本文标题:Modifier 边框(Border)

文章作者:Vinx

发布时间:2023年01月03日 - 09:29

最后更新:2023年09月18日 - 11:37

原始链接:https://blog.vinkvin.com/post/49/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。