I modified my textfield according to this article. TextFieldDefaults
It is perfectly fine it is enabled but if i disable it textcolor is not changing like OutlinedTextField. It's textcolor still behave like it's enabled. What should i do ?
val colors = TextFieldDefaults.outlinedTextFieldColors()
val text = "+56"
BasicTextField(
value = text,
onValueChange = {},
interactionSource = interactionSource,
enabled = false,
singleLine = true,
textStyle = TextStyle.Default,
modifier = modifier
.width(IntrinsicSize.Min)
.layoutId("country_code"),
){
TextFieldDefaults.OutlinedTextFieldDecorationBox(
value = "+56",
enabled = false,
singleLine = true,
innerTextField = it,
visualTransformation = VisualTransformation.None,
interactionSource = interactionSource,
colors = colors
)
}
I want to make this.
It's the my code's result. As you can see border is disabled but
the text is still enabled.
Set the color of your BasicTextField's textStyle to the color from TextFieldDefaults.outlinedTextFieldColors()
val colors = TextFieldDefaults.outlinedTextFieldColors()
val enabled = false
OutlinedTextField(
textStyle = TextStyle.Default.copy(color = colors.textColor(enabled).value),
...
)
You can use LocalTextStyle property to replace text color.
textStyle = LocalTextStyle.current.copy(color = Gray)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With