Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TextInputLayout hint color

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?

like image 975
Veronnie Avatar asked Jun 02 '15 07:06

Veronnie


People also ask

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

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

like image 177
MFQ Avatar answered Oct 21 '22 16:10

MFQ