How to determine if an Android device is Landscape or Portrait
A step by step guide to determining if an Activity or Composable is landscape or portrait on an Android Device using Kotlin and Jetpack Compose.
Step One: Create the Utility
In the Android Studio project, create a file called isLandscape.kt and paste in the code below.
Please note that there are two functions as one can be called anywhere whilst the other can only be called within a Composable.
Step Two: Test
Run the app and rotate the device or emulator and confirm that the function registers landscape and portrait correctly.
Any Questions?
We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.