唯客微博客

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

0%

Jetpack Compose组件-平面(Surface)

Jetpack Compose组件-平面(Surface)

平面(Surface)

将很多的组件摆放在这个平面之上,我们可以设置这个平面的边框,圆角,颜色等等。

Surface实际上是Box的重新包装。

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
47
48
49
50
51
52
53
54
@Composable
fun Surface(
// 修饰符
modifier: Modifier = Modifier,
// 形状
shape: Shape = RectangleShape,
// 颜色
color: Color = MaterialTheme.colors.surface,
// 内容颜色
contentColor: Color = contentColorFor(color),
// 边框
border: BorderStroke? = null,
// 高度(阴影)
elevation: Dp = 0.dp,
content: @Composable () -> Unit
): Unit

@ExperimentalMaterialApi
@Composable
fun Surface(
// 是否选中
selected: Boolean,
// 点击回调
onClick: () -> Unit,
// 点击使能
enabled: Boolean = true,
// 点击状态源
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
// 其余参数参照上方第一个
): Unit

@ExperimentalMaterialApi
@Composable
fun Surface(
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
// 选中使能
enabled: Boolean = true,
// 选中状态源
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
// 其余参数参照上方第一个
): Unit

@ExperimentalMaterialApi
@Composable
fun Surface(
// 点击回调
onClick: () -> Unit,
// 点击使能
enabled: Boolean = true,
// 点击状态源
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
// 其余参数参照上方第一个
): Unit
-------------本文结束感谢您的阅读-------------

本文标题:Jetpack Compose组件-平面(Surface)

文章作者:Vinx

发布时间:2023年01月13日 - 09:53

最后更新:2023年09月19日 - 08:39

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

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