kotlin android 撰写,:aristidev;登录屏幕不像教程那样工作

问题描述 投票:0回答:1

@可组合 有趣的PasswordField(密码:字符串,onTextFieldChanged:(字符串) - >单位){ 文本域( 值 = 密码,onValueChange = {onTextFieldChanged(it)}, 占位符 = {Text(text = "Contraseña")}, 修饰符 = Modifier.fillMaxWidth(), 键盘选项 = 键盘选项(键盘类型 = 键盘类型.密码), 单行=真, 最大行数 = 1, 颜色= TextFieldDefaults.run { 集装箱箱( 文本颜色 = 颜色(0xFF636262), 背景颜色 = 颜色(0xFFDEDDDD), focusIndicatorColor = Color.Transparent, unfocusedIndicatorColor = Color.Transparent )

Quisiera un ejemplo de como sería este codigopractiizado al año 2024,ya que el youtube 教程,es del año 2021。

android kotlin overloading resolution ambiguity
1个回答
0
投票

我用谷歌翻译来翻译你的问题,翻译如下

我想要一个该代码的示例,更新到 2024 年,因为 YouTube 教程是从 2021 年开始的。

如果您使用

material3
,您可以使用
TextFieldDefaults.colors
自定义
TextField
的颜色。这是参数列表。

      TextFieldDefaults.colors(
            focusedIndicatorColor= Color.Transparent,//set your color
            unfocusedIndicatorColor= Color.Transparent,//set your color
            disabledIndicatorColor= Color(0x00000000),//set your color
            errorIndicatorColor= Color(0x00000000),//set your color
            focusedLeadingIconColor= Color(0x00000000),//set your color
            unfocusedLeadingIconColor= Color(0x00000000),//set your color
            disabledLeadingIconColor= Color(0x00000000),//set your color
            errorLeadingIconColor= Color(0x00000000),//set your color
            focusedTrailingIconColor= Color(0x00000000),//set your color
            unfocusedTrailingIconColor= Color(0x00000000),//set your color
            disabledTrailingIconColor= Color(0x00000000),//set your color
            errorTrailingIconColor= Color(0x00000000),//set your color
            focusedLabelColor= Color(0x00000000),//set your color
            unfocusedLabelColor= Color(0x00000000),//set your color
            disabledLabelColor= Color(0x00000000),//set your color
            errorLabelColor= Color(0x00000000),//set your color
            focusedPlaceholderColor= Color(0x00000000),//set your color
            unfocusedPlaceholderColor= Color(0x00000000),//set your color
            disabledPlaceholderColor= Color(0x00000000),//set your color
            errorPlaceholderColor= Color(0x00000000),//set your color
            focusedSupportingTextColor= Color(0x00000000),//set your color
            unfocusedSupportingTextColor= Color(0x00000000),//set your color
            disabledSupportingTextColor= Color(0x00000000),//set your color
            errorSupportingTextColor= Color(0x00000000),//set your color
            focusedPrefixColor= Color(0x00000000),//set your color
            unfocusedPrefixColor= Color(0x00000000),//set your color
            disabledPrefixColor= Color(0x00000000),//set your color
            errorPrefixColor= Color(0x00000000),//set set your color
            focusedSuffixColor= Color(0x00000000),//set your color
            unfocusedSuffixColor= Color(0x00000000),//set your color
            disabledSuffixColor= Color(0x00000000),//set your color
            errorSuffixColor= Color(0x00000000),//set your color
        )

如果您想要代码完全匹配,这就是它的样子

@Composable 
fun PasswordField(
    password: String, 
    onTextFieldChanged: (String) -> Unit = {}
) {
    TextField(
        value = password,
        onValueChange = {
            onTextFieldChanged(it)
        },
        placeholder = {
            Text(text = "Contraseña")
        },
        modifier = Modifier
            .fillMaxWidth()
            .background(Color(0xFFDEDDDD)),
        colors = TextFieldDefaults.colors(
            focusedIndicatorColor= Color.Transparent,
            unfocusedIndicatorColor= Color.Transparent,
        ),
        keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
        singleLine = true,
        maxLines = 1,
    )
}
© www.soinside.com 2019 - 2024. All rights reserved.