犀利的小眼神

Compose LazyColumn添加分割线

fun Todo(todos:List<TodoItem>){
   LazyColumn(
            modifier = Modifier.weight(1f)
        ) {
            items(
                todos,
                key = { todo -> todo.id }
            ) {
                //列表项
                TodoRow(
                    it,
                    Modifier.fillMaxWidth()
                )
                //添加分割线

                if (todos.indexOf(it) != todos.lastIndex){
                    Box(
                        modifier = Modifier
                            .fillMaxWidth()
                            .padding(horizontal = 8.dp)
                            .height(1.dp) // 设置分割线的高度
                            .background(Color.Black) // 设置分割线的颜色
                    )
                }
            }
        }
    }

image

posted on 2024-05-10 12:14  犀利的小眼神  阅读(73)  评论(0编辑  收藏  举报

导航