How to set colorControlActivated for TextInputLayout in programmatically ?
because i want to set underline color. and my color is string (#....) not in R.color thanks!
How to set colorControlActivated for TextInputLayout in programmatically ?
because i want to set underline color. and my color is string (#....) not in R.color thanks!
With the TextInputLayout
included in the Material Components Library you can use the method:
textInputLayout.setBoxStrokeColor(..)
With a FilledBox style which is the default style (Widget.MaterialComponents.TextInputLayout.FilledBox
) the underline color is the strokeColor.
In xml you can use app:boxStrokeColor
.
You should use a selector. The default value is something like:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorPrimary" android:state_focused="true"/>
<!-- 4% overlay over 42% colorOnSurface -->
<item android:alpha="0.46" android:color="@color/colorOnSurface" android:state_hovered="true"/>
<item android:alpha="0.38" android:color="@color/colorOnSurface" android:state_enabled="false"/>
<item android:alpha="0.42" android:color="@color/colorOnSurface"/>
</selector>