14

I'm using new Google design library (com.android.support:design:22.2.0) and I have problem with android.support.design.widget.TextInputLayout.

If I set its EditText programmatically, floating hint color is gray instead of accent color. It works if user fills field (EditText) itself or if he changes preddefined value of field.

This is my code:

<android.support.design.widget.TextInputLayout
        android:layout_height="wrap_content"
        android:layout_width="match_parent">
        <EditText
            android:id="@+id/register_username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="@string/register_username"
            android:inputType="text"/>
</android.support.design.widget.TextInputLayout>

After user clicks some button it fill field via setText() method of EditText and floating hint becomes gray. Is it bug or I'm missing something?

Veronnie
  • 313
  • 1
  • 3
  • 8
  • Please check my [answer here](http://stackoverflow.com/a/37090469/1252158) to change the label color of your choice – Summved Jain May 07 '16 at 15:48

4 Answers4

24

put android:textColorHint="@color/your_color" inside TextInputLayout

MFQ
  • 839
  • 8
  • 14
6

Use android.support.v7.widget.AppCompatEditText instead of EditText and your problems should be resolved. Also make sure your gradle settings are as follows below:

compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:design:22.2.0'
Lucas Crawford
  • 3,078
  • 2
  • 14
  • 25
4

See here

In particular android.support.design:hintTextAppearance="@style/TextAppearance.AppCompat">

Community
  • 1
  • 1
X3Btel
  • 1,408
  • 1
  • 13
  • 21
  • Hint color is ok, it is only broken when I set text to EditText programmatically. I think it should be accent color automatically. I try this workaround but I don't like this solution :-) – Veronnie Jun 02 '15 at 13:17
  • I try and it didn't work. Still after call setText method hint goes gray. – Veronnie Jun 02 '15 at 13:25
1

Below code worked for me :

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

         <EditText
              android:id="@+id/email"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:background="@drawable/white_box"
              android:hint="@string/prompt_email"
              android:inputType="textEmailAddress"
              android:maxLines="1"
              android:singleLine="true"
              android:textColor="@color/text_color"
              android:textColorHighlight="@color/text_color"
              android:textColorHint="@color/text_color"
              android:drawableRight="@drawable/ic_action_email"/>
 </android.support.design.widget.TextInputLayout>

textColorHint hint color when edittext is not focused and android:textColorHighlight hint color in floating mode

Jaiprakash Soni
  • 4,100
  • 5
  • 36
  • 67