Socheat KHAUV
06/02/2020, 4:11 PMHorizontalScroller {
for (i in 1..100) {
onCommit(callback = {
println("onCommit ${i}")
})
onDispose {
println("onDispose ${i}")
}
onPreCommit {
println("onPreCommit ${i}")
}
onActive {
println("onActive ${i}")
}
Canvas(modifier = Modifier.preferredSize(200.dp)) {
println("drawRect ${i}")
drawRect(
color = if (i % 2 == 0) Color.Blue else Color.Green,
alpha = 1f,
topLeft = this.center - this.center
)
}
}
}
drawRect 1, drawRect 2 ... drawRect 100 was printed in the logs, look like the abstraction is do a pre draw and cache its drawn contents.
is there a way that I could get a callback when the canvas is will be on/off the screen, and and force redraw it again ?