I'm trying to customize a TextInputLayout with material style. I managed to set the focused state to the colors I want:
Using
<com.google.android.material.textfield.TextInputLayout style="@style/LoginTextInputLayoutStyle" android:theme="@style/LoginTextInputLayoutStyle" android:textColorHint="#fff" app:boxStrokeColor="#fff" .....> <EditText ...
where the style is:
<style name="LoginTextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"> <item name="colorAccent">#fff</item> </style>
But when the textinput is not focused I get this look:
How can I change the color of the black line to be white too?
To change the hint color you have to use these attributes: hintTextColor and android:textColorHint . To change the bottom line color you have to use the attribute: boxStrokeColor .
Android TexInputLayout extends LinearLayout. The primary use of a TextInputLayout is to act as a wrapper for EditText(or its descendant) and enable floating hint animations. Rule of Thumb : TextInputLayout should wrap TextInputEditText instead of the normal EditText.
Use this style to apply border color and border width like this :
<style name="LoginTextInputLayoutStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"> <item name="boxStrokeColor">#fff</item> <item name="boxStrokeWidth">2dp</item> </style>
get Additional details about styling from this link
Add below line in your colors.xml
file that overrides default color for TextInputLayout
<color name="mtrl_textinput_default_box_stroke_color" tools:override="true">#fff</color>
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