I have been trying to use the new compose SearchBar composable. Everything is going fine except for the fact that I can't change the color of the search input text field.
here my code:
SearchBar(
...
colors = SearchBarDefaults.colors(
inputFieldColors = TextFieldDefaults.colors(
unfocusedContainerColor = Color.Red,
focusedContainerColor = Color.Red,
focusedIndicatorColor = Color.Red,
unfocusedIndicatorColor = Color.Red,
disabledIndicatorColor = Color.Red,
)
), tonalElevation = 0.dp
I have set red to see if things are working at all. As you can see in the picture, there is no red at all. The tonalElevation is 0.dp on purpose. Basically I want the text field to have darker background
I just read this from the source code of inputFieldColors
composable.
Creates a TextFieldColors that represents the different colors used in the search bar input field in different states. Only a subset of the full list of TextFieldColors parameters are used in the input field. All other parameters have no effect.
Therefore changing the properties I mentioned in my question will have no effect.