mertceyhan
02/21/2022, 2:01 PMsingleLine = true
on OutlinedTextField
. I’ve checked the case on EditText that comes from View class but it worked well. Is this bug or something else? Here is the code:
Column(modifier = Modifier.padding(16.dp)) {
var outlinedTextFieldValue by remember { mutableStateOf("") }
OutlinedTextField(
value = outlinedTextFieldValue,
onValueChange = { newValue ->
outlinedTextFieldValue = newValue
},
placeholder = { Text(text = "OutlinedTextField") },
singleLine = true,
maxLines = 1
)
AndroidView(factory = { context ->
EditText(context).apply {
hint = "EditText build by AndroidView"
maxLines = 1
isSingleLine = true
}
})
}
"\n"
with a space " "
var outlinedTextFieldValue by remember { mutableStateOf("") }
OutlinedTextField(
value = outlinedTextFieldValue,
onValueChange = { newValue ->
outlinedTextFieldValue = newValue.replace("\n", " ")
},
placeholder = { Text(text = "OutlinedTextField") },
singleLine = true,
maxLines = 1
)
Siyamed
02/21/2022, 8:32 PMmertceyhan
02/21/2022, 10:41 PMonValueChange
. https://blog.shreyaspatil.dev/filtering-and-modifying-text-input-in-jetpack-compose-way. We’ve written a SingleLineVisualTransformation
and it works fine right now. But we weren’t expecting that even though maxLines = 1
. I’ll create a ticket and I’ll consider the different line breaks in char. Thanks a lot SiyamedBasicTextField
and it has maxLines
and singleLine
parameters but it works well on the copy-paste case. The implementation of it is different than OutlinedTextField
.
https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/package-summary#BasicTextField(kotlin.St[…]s.Brush,kotlin.Function1)Siyamed
02/21/2022, 11:03 PM