Is there native way to hide softKeyboard inside Co...
# compose
y
Is there native way to hide softKeyboard inside Composable? Or need to use activity / fragment?
p
There is a class called:
SoftwareKeyboardController
and you can access its instance from
Copy code
TextField(onImeActionPerformed = { imeAction, keyboardController -> })
p
If you have a
TextField
, one way is to invoke
hideSoftwareKeyboard()
on
SoftwareKeyboardController
, but it requires keeping a reference to this controller when
onTextInputStarted: (SoftwareKeyboardController) -> Unit
is invoked.
@Piotr Prus Unfortunately,
onImeActionPerformed
is deprecated in alpha12 😕
p
oh, didnt know. I am using 08 atm
p
it’s replaced with
KeyboardActions
, with new callbacks (all missing
SoftwareKeyboardController
reference) https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/KeyboardActions
👍 2
y
@pawegio Thanks. it’s works