https://kotlinlang.org logo
#compose
Title
# compose
y

Yuri Drigin

02/16/2021, 12:32 PM
Is there native way to hide softKeyboard inside Composable? Or need to use activity / fragment?
p

Piotr Prus

02/16/2021, 12:52 PM
There is a class called:
SoftwareKeyboardController
and you can access its instance from
Copy code
TextField(onImeActionPerformed = { imeAction, keyboardController -> })
p

pawegio

02/16/2021, 12:53 PM
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

Piotr Prus

02/16/2021, 12:54 PM
oh, didnt know. I am using 08 atm
p

pawegio

02/16/2021, 12:56 PM
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

Yuri Drigin

02/16/2021, 1:56 PM
@pawegio Thanks. it’s works