I made a custom view which consists of two TextInputLayout
Here's the view:
I set the underline color to blue through xml applying a selector to the boxStrokeColor of both ViewGroups. Both of them should change to red at some point, but when I change the same property programatically, only the one that is focused changes color.
fun setState(state: State) {
val (color, visibility) = when (state) {
State.NORMAL -> Pair(R.color.selector_key_input, View.INVISIBLE)
State.ERROR -> Pair(R.color.selector_key_input_error, View.VISIBLE)
}
firstInputLayout.boxStrokeColor = ContextCompat.getColor(context, color)
secondInputLayout.boxStrokeColor = ContextCompat.getColor(context, color)
incorrectTextView.visibility = visibility
}
This seems to be the behavior Google has added to these components. Any ideas how to set the underline color programatically?
This is the red selector, and the blue is the same. The only difference is the blue is applied directly through xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:color="@color/red"/>
<item android:state_hovered="true" android:color="@color/red"/>
<item android:state_focused="true" android:color="@color/red"/>
<item android:color="@color/red"/>
</selector>