出于某種原因,在嘗試在 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
)
)
}
無論我在此處的引數串列中的何處添加“顏色”,它都不起作用。我回來了:
None of the following functions can be called with the arguments supplied.
我根本不了解這里的建構式,我什至將我的代碼更改為與在線其他人更相似,但仍然得到相同的錯誤。
撰寫版本為 1.0.2
uj5u.com熱心網友回復:
TextField 沒有color引數。你必須colors改用
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/451245.html
標籤:安卓 科特林 用户界面 android-jetpack-compose
上一篇:在Flutter中制作搜索欄
下一篇:vue firebaseauth輸出console.logofauth/internal-error而不是auth/invalid-password
