fengdai
06/07/2022, 1:33 PMAndroidView ’s factory lambda will always be called twice when used in movableContentOf . Does anyone know why?
val content = movableContentOf {
AndroidView(factory = { context ->
SomeView(context)
})
}
val content2 = movableContentOf {
// content2
}
val isLandscape =
LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE
if (!isLandscape) Column {
content()
content2()
} else Row {
content()
content2()
}Zach Klippenstein (he/him) [MOD]
06/07/2022, 3:32 PMfengdai
06/08/2022, 1:43 AMmovableContentOf with remember. The correct code is:
val content = remember {
movableContentOf {
AndroidView(factory = { context ->
SomeView(context)
})
}
}
val content2 = remember {
movableContentOf {
// content2
}
}
val isLandscape =
LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE
if (!isLandscape) Column {
content()
content2()
} else Row {
content()
content2()
}Zach Klippenstein (he/him) [MOD]
06/08/2022, 1:52 AMfengdai
06/08/2022, 1:54 AM