Issue
Is there any Orientation helpers class in Jetpack Compose, like Flutter has https://flutter.dev/docs/cookbook/design/orientation ?? I need to know when orientation have been changed to adjust my layout properly.
Solution
We can use LocalConfiguration
to listen for the orientation changes
@Composable
fun ConfigChangeExample() {
val configuration = LocalConfiguration.current
when (configuration.orientation) {
Configuration.ORIENTATION_LANDSCAPE -> {
Text("Landscape")
}
else -> {
Text("Portrait")
}
}
}
Note: This will not help to listen to the configuration change, This will just help to get the current Configuration.
Answered By - Muthukrishnan Rajendran
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.