Savo Bozic
04/24/2025, 4:26 PMOutlinedTextField
and have set its KeyboardOptions
to showKeyboardOnFocus = false
. According to the documentation, this should prevent the soft keyboard from appearing automatically when the TextField gains focus.
However, despite this setting, the soft keyboard is still showing up when the field receives focus.
Has anyone else encountered this specific issue where the showKeyboardOnFocus = false
flag is not working as expected,?
ComposeBom version used is “2025.04.00”.
Minimal code example to reproduce it is in thread,Savo Bozic
04/24/2025, 4:26 PM@Composable
fun ScannerScreen() {
var barCode by remember { mutableStateOf("") }
var scannedBarCode by remember { mutableStateOf("") }
val focusRequester = remember { FocusRequester() }
val focusManager = LocalFocusManager.current
LaunchedEffect(Unit) {
focusRequester.requestFocus()
}
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp)
) {
OutlinedTextField(
value = barCode,
onValueChange = { barCode = it },
label = { Text("Barcode") },
placeholder = { Text("Enter Barcode") },
singleLine = true,
keyboardOptions = KeyboardOptions.Default.copy(
keyboardType = KeyboardType.Number,
imeAction = ImeAction.Done,
showKeyboardOnFocus = false
),
keyboardActions = KeyboardActions(
onDone = {
scannedBarCode = barCode
focusManager.clearFocus()
}
),
modifier = Modifier
.fillMaxWidth()
.focusRequester(focusRequester)
)
if (scannedBarCode.isNotBlank())
Text(
text = "Entered(Scanned) Barcode: $scannedBarCode",
style = MaterialTheme.typography.bodyMedium
)
}
}
Ceph
04/25/2025, 7:37 AMSavo Bozic
04/25/2025, 7:38 AMCeph
04/25/2025, 7:47 AM