Home > Net >  OutlinedTextField's Text Color Does Not Change When Disabled
OutlinedTextField's Text Color Does Not Change When Disabled

Time:07-13

I modified my textfield according to this article. WhatI I want to make this.

WhatsHappening It's the my code's result. As you can see border is disabled but the text is still enabled.

CodePudding user response:

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),
    ...
)

CodePudding user response:

It seems a bug.
As workaround you can use something like:

   val colors = TextFieldDefaults.outlinedTextFieldColors()
   val enabled = false
   val textColor = colors.textColor(enabled).value
   val mergedTextStyle = TextStyle.Default.merge(TextStyle(color = textColor))

    BasicTextField(
        //your implementation
        textStyle = mergedTextStyle,
        ) {
        TextFieldDefaults.OutlinedTextFieldDecorationBox(
             //your implementation
        )
    }

enter image description here

  • Related