how to change color of TextinputLayout's label and edittext underline android

textinputlayout hint color programmatically
how to change the floating label color of textinputlayout
android-textinputlayout underline color
textinputlayout error background color
textinputlayout cursor color
customize textinputlayout android
android how to change hint color
textinputlayout background color

I am using android design library's TextinputLayout. But couldn't customize the hint color, label color and the underline color of EditText inside TextinputLayout. Please help.

Change bottom line color:
<item name="colorControlNormal">#c5c5c5</item>
<item name="colorControlActivated">@color/accent</item>
<item name="colorControlHighlight">@color/accent</item>

For more info check this thread.

Change hint color when it is floating
<style name="MyHintStyle" parent="@android:style/TextAppearance">
    <item name="android:textColor">@color/main_color</item>
</style>

and use it like this:

<android.support.design.widget.TextInputLayout
    ...
    app:hintTextAppearance="@style/MyHintStyle">
Change hint color when it is not a floating label:
<android.support.design.widget.TextInputLayout
    ...
    app:hintTextAppearance="@style/MyHintStyle"
    android:textColorHint="#c1c2c4">

Thanks to @AlbAtNf

how to change color of TextinputLayout's label and edittext , Change hint color when it is not a floating label: <android.support.design.widget. TextInputLayout app:hintTextAppearance="@style/MyHintStyle"� Please follow the below steps : 1. Open your project’s build.gradle ( Module : app ) file. 2. Please add below code inside your build.gradle ( Module : app ) file. compile 'com.android.support:appcompat-v7:24.0.0' compile 'com.android 3. Screenshot of build.gradle ( Module : app ) file after

Based on Fedor Kazakov and others answers, I created a default config.

styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
    </style>

    <style name="Widget.Design.TextInputLayout" parent="AppTheme">
        <item name="hintTextAppearance">@style/AppTheme.TextFloatLabelAppearance</item>
        <item name="errorTextAppearance">@style/AppTheme.TextErrorAppearance</item>
        <item name="counterTextAppearance">@style/TextAppearance.Design.Counter</item>
        <item name="counterOverflowTextAppearance">@style/TextAppearance.Design.Counter.Overflow</item>
    </style>

    <style name="AppTheme.TextFloatLabelAppearance" parent="TextAppearance.Design.Hint">
        <!-- Floating label appearance here -->
        <item name="android:textColor">@color/colorAccent</item>
        <item name="android:textSize">20sp</item>
    </style>

    <style name="AppTheme.TextErrorAppearance" parent="TextAppearance.Design.Error">
        <!-- Error message appearance here -->
        <item name="android:textColor">#ff0000</item>
        <item name="android:textSize">20sp</item>
    </style>

</resources>

activity_layout.xml

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <android.support.v7.widget.AppCompatEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Text hint here"
        android:text="5,2" />

</android.support.design.widget.TextInputLayout>

Focused:

Without focus:

Error message:

Change EditText hint color when using TextInputLayout, Define android:textColorHint in your application theme: <style name="AppTheme " parent="Theme.AppCompat.NoActionBar"> <item� Change TextInputLayout underline color in Android Change TextInputLayout underline color in Android To change the underline color of the TextInputLayout, we can use colorControlNormal and colorControlActivated in the theme file. <style name="myTextInputLabel" parent="TextAppearance.AppCompat"> <!--

With the Material Components Library you can use the com.google.android.material.textfield.TextInputLayout.

You can apply a custom style to change the colors.

To change the hint color you have to use these attributes: hintTextColor and android:textColorHint.

<style name="Custom_textinputlayout_filledbox" parent="@style/Widget.MaterialComponents.TextInputLayout.FilledBox">
    <!-- The color of the label when it is collapsed and the text field is active -->
    <item name="hintTextColor">?attr/colorPrimary</item>

    <!-- The color of the label in all other text field states (such as resting and disabled) -->
    <item name="android:textColorHint">@color/selector_hint_text_color</item>
</style>

You should use a selector for the android:textColorHint. Something like:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:alpha="0.38" android:color="?attr/colorOnSurface" android:state_enabled="false"/>
  <item android:alpha="0.6" android:color="?attr/colorOnSurface"/>
</selector>

To change the bottom line color you have to use the attribute: boxStrokeColor.

<style name="Custom_textinputlayout_filledbox" parent="@style/Widget.MaterialComponents.TextInputLayout.FilledBox">
    ....
    <item name="boxStrokeColor">@color/selector_stroke_color</item>
</style>

Also in this case you should use a selector. Something like:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:color="?attr/colorPrimary" android:state_focused="true"/>
  <item android:alpha="0.87" android:color="?attr/colorOnSurface" android:state_hovered="true"/>
  <item android:alpha="0.12" android:color="?attr/colorOnSurface" android:state_enabled="false"/>
  <item android:alpha="0.38" android:color="?attr/colorOnSurface"/>
</selector>

You can also apply these attributes in your layout:

<com.google.android.material.textfield.TextInputLayout
    style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
    app:boxStrokeColor="@color/selector_stroke_color"
    app:hintTextColor="?attr/colorPrimary"
    android:textColorHint="@color/selector_hint_text_color"
    ...>

TextInputLayout proper Theming. Update: Part 2: Material…, You are now ready to style your Text Fields! Extra Credit: This article, will show you how to use state-selectors to provide different colours for� How to Change the color of underline of TextInputLayout? How to Change the color of underline of TextInputLayout? To change the underline color of the TextInputLayout, we can use colorControlNormal and colorControlActivated in the theme file. <style name="myTextInputLabel" parent="TextAppearance.AppCompat"> <!--

Add this attribute in Edittext tag and enjoy:

 android:backgroundTint="@color/colorWhite"

How to Change the Floating Label Color of TextInputLayout?, To change the floating label color of TextInputLayout, we can use app:hintTextAppearance attribute in TextInputLayout. To change the floating label color, you can use this in your app theme. how to change color of TextinputLayout's edittext underline android [duplicate] Ask Question Asked 3 years, 8 months ago. Active 3 years, 2 months ago.

This Blog Post describes various styling aspects of EditText and AutoCompleteTextView wrapped by TextInputLayout.

For EditText and AppCompat lib 22.1.0+ you can set theme attribute with some theme related settings:

<style name="StyledTilEditTextTheme">
   <item name="android:imeOptions">actionNext</item>
   <item name="android:singleLine">true</item>
   <item name="colorControlNormal">@color/greyLight</item>
   <item name="colorControlActivated">@color/blue</item>
   <item name="android:textColorPrimary">@color/blue</item>
   <item name="android:textSize">@dimen/styledtil_edit_text_size</item>
</style>

<style name="StyledTilEditText">
    <item name="android:theme">@style/StyledTilEditTextTheme</item>
    <item name="android:paddingTop">4dp</item>
</style>

and apply them on EditText:

<EditText
    android:id="@+id/etEditText"
    style="@style/StyledTilEditText"

For AutoCompleteTextView things are more complicated because wrapping it in TextInputLayout and applying this theme breaks floating label behaviour. You need to fix this in code:

private void setStyleForTextForAutoComplete(int color) {
    Drawable wrappedDrawable =     DrawableCompat.wrap(autoCompleteTextView.getBackground());
    DrawableCompat.setTint(wrappedDrawable, color);
    autoCompleteTextView.setBackgroundDrawable(wrappedDrawable);
}

and in Activity.onCreate:

setStyleForTextForAutoComplete(getResources().getColor(R.color.greyLight));
autoCompleteTextView.setOnFocusChangeListener((v, hasFocus) -> {
    if(hasFocus) {
        setStyleForTextForAutoComplete(getResources().getColor(R.color.blue));
    } else {
        if(autoCompleteTextView.getText().length() == 0) {  
              setStyleForTextForAutoComplete(getResources().getColor(R.color.greyLight));
        }
    }
});

[TextInputLayout] text color � Issue #673 � material-components , You can change the input text color via the edit text's android:textColor attribute in the edit text directly or in a style that extends a� Actually, to change just the error message color, you can set textColorError in your theme (and also set colorControlNormal and colorControlActivated for the general widget and hint text color). TextInputLayout picks up that attribute. NOTE: if you set errorTextAppearance to a custom style then textColorError will have no effect.

Change the cursor color via styling � Issue #820 � material , Looks like the TextInputLayout and TextInputEditTextLayout are defaulting the cursor (and cursor bubble) color to primary color. I tested it by� change your colorAccent to your desired color inside your Theme,this will change your EditText line,Cursor as well as your hint. or you can also include this style inside your style.xml. <style name="TextLabel" parent="TextAppearance.AppCompat"> <!--. Hint color and label color in FALSE state --> <item name="android:textColorHint">@android:color/black</item> <item name="android:textSize">20sp</item> <!--.

TextInputLayout, Returns the text color used by the error message in current state. Drawable, getErrorIconDrawable(). Returns the drawable currently used for the� If you want to set the color for the outline box in unfocused mode instead of the default black, you have to add this line in colors.xml file which will override the default color for the outline box. copy this line as it is. you can change color to what you want.

Anyone tried customizing the new TextInputLayout (EditText with , now but I'm finding it hard to customize (colors). What's the best way to change the EditText (inside TextInputLayout) color, pressed color, floating hint color etc. Use textColorHint to set the color that you want as the Hint color for the EditText. The thing is that Hint in the EditText disappears not when you type something, but immediately when the EditText gets focus (with a cool animation). You will notice this clearly when you switch focus away and to the EditText.

Comments
  • It should have the accent color according to design guidelines right?
  • ya, but I will have many editTexts with colors different from theme's accent color.
  • possible duplicate of EditText underline below text property
  • Please check my answer here to change the label color
  • I could change underline reliably in both focused and unfocused state by using custom background drawable specified in stackoverflow.com/a/36543554/2413303
  • I am not able to change hint color (when its not label).Could you help?
  • I am really concerned about my app size , considering that, any idea on how much addition size is it expected to put on my app?
  • sorry, didn't get your question, please explain more, size in what context, graphics size of app weight (Like apk is of above 20mb or something), and earlier you accept my answer and again you remove your acceptance,can i ask, y so?
  • becoz , I couldn't change hint color following your answer. Some part of it worked for me but this is not complete solution to what I asked.Regarding app size, doesn't adding external library like Material EdiTText increase app size?
  • @NiteshVerma found the solution for setting Hint Color, when it is not a floating lable: simply set android:textColorHint to TextInputLayout in XML.
  • What should I do in order to also get pink color for "Without focus" example?