【发布时间】:2021-04-09 19:54:34
【问题描述】:
我正在使用 Jetpack compose 实现一个 PasswordInput 可组合,它是 Android 开发者网站提供的 literally one of the examples:
@Composable
fun PasswordInput() {
var password by remember { mutableStateOf("admin") }
TextField(
value = password,
onValueChange = { password = it },
label = { Text(text = stringResource(id = R.string.prompt_password)) },
modifier = Modifier
.fillMaxWidth(),
visualTransformation = PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password)
)
}
这里我的默认密码为“admin”,长度为五个字符。它显示五个星号。
但是如果用户在那里按下回车键,密码字段就会变成六个字符。
问题:
- 为什么要这样做?
- 如何修改不这样做?
【问题讨论】:
标签: kotlin android-jetpack-compose