fengdai
movableContentOf
SubcomposeLayout
AndroidView
// When rotate screen, AndroidView recreate its view val content = remember { movableContentOf { isLandscape: Boolean -> AndroidView(factory = { context -> Log.d("AndroidView", "create view") TextView(context).apply { layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT) } }) { it.text = if (isLandscape) "Landscape" else "Portrait" } } } val isLandscape = LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE BoxWithConstraints { if (!isLandscape) { content(false) } } if (isLandscape) { content(true) }
Andrey Kulikov
A modern programming language that makes developers happier.