![](https://i-blog.csdnimg.cn/blog_migrate/eb71bcba41379b3fde581cdf200a9425.png)
01. Compose 可组合组件之Row And Column
02. Compose 可组合组件之 属性 modifier
03. Compose 可组合组件之Card 图片
04. Compose 字体
05. Compose State
06. Compose SnackBar
07. Compose List
08. Compose ConstrainLayout
09. Compose Button
10. Compose CheckBox
11. Compose 对于复杂界面的尝试
12. Compose 之原生xml布局加入Compose代码
13. Compose 之Compose代码插入xml布局
14. Compose 之简易朋友圈列表
15. Compose 使用CameraX
16. Compose 权限申请Permission
17. Compose 时钟Clock的绘制
class ClockActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Column(modifier = Modifier.fillMaxSize()) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(0.5f)
) {
Clock()
}
Box(
contentAlignment = Alignment.Center,
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(0.5f)
) {
Clock1()
}
}
}
}
@Composable
fun Clock1() {
val hour = remember {
mutableStateOf(0f)
}
val minute = remember {
mutableStateOf(0f)
}
val second = remember {
mutableStateOf(0f)
}
LaunchedEffect(key1 = "") {
while (true) {
val cal = Calendar.getInstance()
hour.value = cal.get(Calendar.HOUR).toFloat()
minute.value = cal.get(Calendar.MINUTE).toFloat()
second.value = cal.get(Calendar.SECOND).toFloat()