There was no problem when I first did it, but when I added more code and compiled it, I saw that the placeholder did not appear. I can’t understand why.
Box(modifier = modifier) {
OutlinedTextField(value = searchKey, onValueChange = onValueChange,
keyboardActions = KeyboardActions(onDone = { onSearch(searchKey) }),
maxLines = 1,
singleLine = true,
textStyle = TextStyle(color = MaterialTheme.colorScheme.tertiary),
shape = RoundedCornerShape(12.dp),
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 10.dp, vertical = 6.dp)
.background(color = Color.White, CircleShape),
colors = TextFieldDefaults.colors(
focusedContainerColor = Color.White,
unfocusedContainerColor = Color.White,
disabledContainerColor = Color.White
),
leadingIcon = {
Icon(
imageVector = Icons.Filled.Search,
contentDescription = "Search Icon"
)
},
placeholder = { Text(text = "Search") }
)
}
But when i define a mutablestate called text in the searchbar and write like this, the placeholder appears again.
TextField(value = text.value, onValueChange = {
text.value=it
},
keyboardActions = KeyboardActions(onDone = {onSearch(text.value)}),
New contributor
Mehmet is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.