我做了一个可组合的功能TextInput....但在这个无法看到光标在初始状态,也当我设置KeyboardType.密码密码选项不出现我出现作为正常文本只有我无法纠正的问题,我做错了...以及我也是新的喷气背包组成
通用功能
@Composable
fun TextInput(
label: String,
value: TextFieldValue,
onValueChange: (TextFieldValue) -> Unit,
keyboardType: KeyboardType
) {
BasicTextField(
value = value,
onValueChange = onValueChange,
modifier = Modifier
.fillMaxWidth()
.padding(
start = ZingSalesAppTheme.dimensions.dimen_10dp,
top = ZingSalesAppTheme.dimensions.dimen_10dp,
end = ZingSalesAppTheme.dimensions.dimen_10dp
)
.padding(
start = ZingSalesAppTheme.dimensions.dimen_10dp,
end = ZingSalesAppTheme.dimensions.dimen_10dp
),
textStyle = TextStyle(
color = Color.Black,
textAlign = TextAlign.Start
),
singleLine = true,
cursorBrush = SolidColor(Color.Black),
keyboardOptions = KeyboardOptions(keyboardType = keyboardType),
decorationBox = { innerTextFeild ->
Column {
if (value.text.isEmpty()) {
Text(
text = label,
style = ZingSalesAppTheme.typography.body1_medium.merge(
TextStyle(textAlign = TextAlign.Start).copy(
color = ZingSalesAppTheme.colors.neutral[Colors.TYPE_600.ordinal]
)
),
modifier = Modifier
.fillMaxWidth()
)
} else {
innerTextFeild()
}
Divider(
modifier = Modifier.padding(top = 8.dp),
color = ZingSalesAppTheme.colors.neutral[Colors.TYPE_600.ordinal]
)
}
}
)
}
函数的用法
TextInput(
"Enter Password",
passwordState.value,
onValueChange = { passwordState.value = it },
KeyboardType.Password
)
我已经检查了所有的状态,但找不到方法
1条答案
按热度按时间fhity93d1#
你需要添加visualTransformation,像这样:
如果你不想在显示和隐藏密码之间切换,只需要添加以下代码: