Timo Drick
07/10/2023, 12:45 PM@Composable
fun CustomLayout(
child1: @Composable () -> Unit = {},
child2: @Composable () -> Unit = {},
) {
val cfg = LocalConfiguration.current
val isLandscape by remember(cfg) { derivedStateOf { cfg.orientation == Configuration.ORIENTATION_LANDSCAPE } }
if (isLandscape) {
Row() {
child1()
child2()
}
} else {
Column() {
child1()
child2()
}
}
}
Now my problem is that when the layout changes child1 and child2 getting destroyed and new composables are created.
Normally that does not matter but in my case i do have a AndroidView inside of the child and do not want that the view is recreated when the layout changes. Is there any trick to avoid recreation of the composables in this case?Stylianos Gakis
07/10/2023, 12:53 PMTimo Drick
07/10/2023, 12:57 PM