Jetpack Compose TextField 参数列表;颜色不允许

Jetpack Compose TextField arguments list; color not allowed

出于某种原因,当我尝试在 Compose 中创建 TextField 时,我经常 运行 遇到参数问题,例如:

// this is perfectly fine
@Composable
fun Username() {
val emailState = remember{ mutableStateOf(TextFieldValue())}
TextField(
    modifier = Modifier.fillMaxWidth(),
    label = { Text(text = stringResource(R.string.username_label))},
    value = emailState.value,
    onValueChange = { emailState.value = it },
    shape = RoundedCornerShape(8.dp),
    keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email),
    )
}

但是,如果我尝试插入颜色值,一切都会崩溃:

@Composable
fun Username() {
val emailState = remember{ mutableStateOf(TextFieldValue())}
TextField(
    modifier = Modifier.fillMaxWidth(),
    label = { Text(text = stringResource(R.string.username_label))},
    value = emailState.value,
    onValueChange = { emailState.value = it },
    shape = RoundedCornerShape(8.dp),
    keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email),
    color = TextFieldDefaults.textFieldColors(
        unfocusedIndicatorColor = Color.Transparent,
        focusedIndicatorColor = Color.Transparent
        )
    )
}

无论我在此处的参数列表中的何处添加 'color',它都不会起作用。 我回来了:

None of the following functions can be called with the arguments supplied.

我完全不懂这里的构造函数,我什至将我的代码更改为与网上其他人更相似,但仍然得到相同的错误。

Compose 版本为 1.0.2

TextField 没有 color 参数。 你必须使用 colors 而不是