Created
October 22, 2021 09:31
-
-
Save RaheemJnr/f194c0e0076a0b018e6ff21b8521ed63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExperimentalComposeUiApi | |
@Composable | |
fun ShowKeyboard() { | |
val keyboardController = LocalSoftwareKeyboardController.current | |
var value by remember { mutableStateOf("") } | |
Column( | |
modifier = Modifier.fillMaxSize(), | |
verticalArrangement = Arrangement.Center | |
) { | |
TextField( | |
value = value, | |
onValueChange = { value = it }, | |
modifier = Modifier | |
.padding(8.dp) | |
.fillMaxWidth(), | |
) | |
Spacer(modifier = Modifier.height(12.dp)) | |
Row( | |
modifier = Modifier.fillMaxWidth(), | |
verticalAlignment = Alignment.CenterVertically, | |
horizontalArrangement = Arrangement.SpaceEvenly | |
) { | |
//show keyboard | |
Button( | |
onClick = { | |
keyboardController?.show() | |
} | |
) { | |
Text(text = "Show") | |
} | |
//hide keyboard | |
Button( | |
onClick = { keyboardController?.hide() } | |
) { | |
Text(text = "Hide") | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment