This Kotlin file contains a simple implementation for detecting the visibility of the software keyboard in an Android app using Jetpack Compose.
The MainActivity
class in this file demonstrates how to use WindowInsets.isImeVisible
to check if the software keyboard is visible on the screen. The UI consists of a TextField
for input and a Text
that displays the keyboard visibility status.
- Include this Kotlin file in your Android Jetpack Compose project.
- Run the app and focus on the TextField. The text will update to indicate whether the keyboard is visible.
- Utilizes
WindowInsets.isImeVisible
for keyboard visibility detection. - Simple Compose layout with
Scaffold
andColumn
. - Dynamically updates the UI based on the keyboard's visibility state.
Feel free to fork this gist and contribute to enhancing its functionality or addressing any issues. Suggestions and improvements are always welcome!
Created by Abdelraouf Sabri - Senior Android Developer
This helped, thanks :)