Jetpack Compose学习 Surface

Jetpack Compose学习 -------- Surface

用 Surface 实现 Card 的效果

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
34
35
36
37
38
39
40
41
42
43
44
45
46

@Composable
fun ComposableSample() {
Surface(
//设置形状
shape = RoundedCornerShape(10.dp),
// 设置阴影
elevation = 10.dp,
modifier = Modifier
.fillMaxWidth()
// 外边距
.padding(15.dp)
.clickable { }
) {
Column(
// 内边距
Modifier.padding(15.dp)
) {
Text(
buildAnnotatedString {
append("welcome to ")
withStyle(
style = SpanStyle(
color = Color(0xFF4552B8),
fontWeight = FontWeight.W900,
)
) {
append("Jetpack Compose Playground")
}
})
Text(
buildAnnotatedString {
append("Now you are in the ")
withStyle(
style = SpanStyle(
fontWeight = FontWeight.W900,
)
) {
append("Card")
}
append(" section")
})
}
}
}