I've been trying to get the placeholder text inside of an OutlinedTextField to change color and it is just staying black, no matter what I do. I am using M3 theme and components. I can get everything else to change (text color, border color, etc), just not the placeholder. In my Color.kt file I define all the colors, one of them being onSurface...
val md_theme_dark_onSurface = Color(red = 140, green = 207, blue = 242)
Then in my LoginView.kt I am trying to use that to tell the placeholder what color to be...
val textFieldColor = OutlinedTextFieldDefaults.colors(
focusedPlaceholderColor = MaterialTheme.colorScheme.onSurface,
unfocusedPlaceholderColor = MaterialTheme.colorScheme.onSurface
)
Then set the colors of the outlined text field...
OutlinedTextField(
value = uiState.username,
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next),
onValueChange = { viewModel.setUsername(it) },
placeholder = { Text("Username") },
leadingIcon = {
Image(painter = painterResource(id = R.drawable.user), contentDescription = null)
},
colors = textFieldColor
)
One would think that would change the placeholder in the text field, but it does not. I still get a black placeholder. The border and image are correctly colored and change when focused/unfocused but the placeholder stays black, even in Dark theme.
What can I try next?

use this code, tested its working