Hi all! I'm showing an `Alert Dialog` when I enter...
# compose
m
Hi all! I'm showing an
Alert Dialog
when I enter an invalid email address, as I click on Continue button the keyboard is dismissed and
Alert Dialog
is also displayed, but the position of the
Alert Dialog
starts above the center of the screen and moves to the Center as the keyboard is sliding down to be dismissed. How can I always position it to center?
m
Sounds like you need to forcible dismiss the keyboard before popping up your dialog. This might work for you:
Copy code
val keyboardController = LocalSoftwareKeyboardController.current

Button(onClick = { 
   keyboardController.hide()
   dialogVisible.value = true
}) { ... }
2
That’s assuming your “Continue” button is a regular button, but you could easily enough call this from an ime action i would think. You just have to make sure to get the keyboardController in composable code before using it in a non composable callback.
m
I forgot I asked the question here on Slack and figured out the same solution, came back to post it here and found the same from you 😄 Thank you for your time @mattinger