Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the TextInputLayout outline color

I'm trying to customize a TextInputLayout with material style. I managed to set the focused state to the colors I want:

enter image description here

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:

enter image description here

How can I change the color of the black line to be white too?

like image 573
Addev Avatar asked Jun 12 '18 12:06

Addev


People also ask

How do I change the color of my TextInputLayout line?

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 .

What is a TextInputLayout?

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.


1 Answers

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> 
like image 200
Rutvik Bhatt Avatar answered Oct 11 '22 18:10

Rutvik Bhatt