tv-samples
tv-samples copied to clipboard
Set Focus on TextFiled on load?
Not an issue, Just a question.
I have a login page that i would like to set the focus on the username box automaticly on page load?
i have tried to add val focusRequester = remember { FocusRequester() } val focusRequesterModifier = Modifier.focusRequester(focusRequester)
but can't add modifier to textField Or focusRequester not found?
...... modifier = Modifier .fillMaxWidth() .focusRequester(focusRequester) .....
TvTextField( value = username.value, label = "Username") { username.value = it } TvTextField() -> OutlinedTextField( textStyle = MaterialTheme.typography.bodyLarge, colors = TextFieldDefaults.outlinedTextFieldColors( focusedBorderColor = MaterialTheme.colorScheme.surface, cursorColor = MaterialTheme.colorScheme.surface, focusedLabelColor = MaterialTheme.colorScheme.surface, ), interactionSource = mutableInteractionSource, label = { Text(text = label) }, value = value, visualTransformation = visualTransformation, keyboardOptions = KeyboardOptions(keyboardType = keyboardType), onValueChange = onValueChange, )