代码之家  ›  专栏  ›  技术社区  ›  P.Juni

Jetpack Compose:文本字段颜色被忽略且不应用

  •  0
  • P.Juni  · 技术社区  · 2 年前

    我正在尝试设置/删除文本字段中的颜色,但未应用更改。我想通过设置透明颜色和改变光标颜色来完全移除指示器。文本的颜色似乎很有效。

    为什么不应用它以及如何使其工作?

    代码:

    Column(
        modifier = Modifier
            .fillMaxWidth()
            .border(1.dp, colorResource(id = R.color.dark_smoke), RoundedCornerShape(8.dp))
            .background(colorResource(id = R.color.white_smoke))
    ) {
        TextField(
            value = email.value,
            onValueChange = {
                email.value = it
                loginViewModel.verifyEmail(it.text)
            },
            colors = TextFieldDefaults.textFieldColors(
                cursorColor = colorResource(id = R.color.steel_blue),
                textColor = Color.DarkGray,
                backgroundColor = Color.Transparent,
                focusedIndicatorColor = Color.Transparent,
                unfocusedIndicatorColor = Color.Transparent,
                disabledIndicatorColor = Color.Transparent
            ),
            modifier = Modifier.fillMaxWidth(),
            isError = viewState.isEmailValid.not(),
            label = {
                Text(
                    text = stringResource(R.string.username_hint)
                )
            },
            keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email),
        )
    }
    

    0 回复  |  直到 2 年前
    推荐文章