Mehdi Haghgoo
09/02/2020, 1:52 PM@Composable
fun TodoScreen(
items: List<TodoItem>,
onAddItem: (TodoItem) -> Unit,
onRemoveItem: (TodoItem) -> Unit
) {
Column {
LazyColumnFor(
items = items,
modifier = Modifier.weight(1f),
contentPadding = InnerPadding(top = 8.dp)
) { todo ->
TodoRow(
todo = todo,
onItemClicked = { onRemoveItem(it) },
modifier = Modifier.fillParentMaxWidth()
)
}
// For quick testing, a random item generator button
FloatingActionButton(
shape = CircleShape,
elevation = 8.dp,
icon = {
Row(modifier = Modifier.padding(16.dp)){
Icon(asset = vectorResource(id = R.drawable.add))
Text("Add New Item")
}
},
onClick = { onAddItem(generateRandomTodoItem()) },
modifier = Modifier.gravity(Alignment.CenterHorizontally),
)
}
}
Any ideas why this happens? Do I need a constraint mechanism or something for the FAB?Michał Jurczyk
09/02/2020, 1:56 PMStack(
modifier = Modifier.fillMaxSize()
) {
...
}
flosch
09/02/2020, 2:05 PMMehdi Haghgoo
09/02/2020, 2:06 PMTimo Drick
09/02/2020, 2:06 PMflosch
09/02/2020, 2:08 PMCould you please explain why Scaffold is better for this purpose?Since you also get the
innerPadding
for your bodyContent. Although I am not quite sure now, if that also accounts the FAB or just the top and bottom bars
But apart from that there is also the convenient floatingActionButtonPosition
parameter thereTimo Drick
09/02/2020, 2:11 PM