I have been looking how to change the color that the focused TextInputLayout picks, the colorAccent because I need to do it programmatically.
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/atom_edittext_til"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/atom_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:inputType="text"
android:backgroundTint="@color/greyGhost"
android:textSize="@dimen/_16sp"
android:scrollHorizontally="true"/>
I have that define in my XML
I need to be able to change the green cursor and the underline programmatically because the colors comes from the server. Is there any way to do this?
Thank you
I already try, setBoxStrokeColorStateList, boxStrokeColor, backgroundTintList, if a try to do background.setTint I get a Null Reference From the resource file is not an option Also tried creating an extension
fun TextInputLayout.setDefaultStrokeColor(
color: Int
) {
try {
val defaultStrokeColor = TextInputLayout::class.java.getDeclaredField("defaultStrokeColor")
defaultStrokeColor.isAccessible = true
defaultStrokeColor.set(this, color)
} catch (e: NoSuchFieldException) {
// failed to change the color
}
}
does not work