Hint not visible with TextInputLayout on non focus state

5.3k views Asked by At

I'm using the new TextInputLayout from the Android design library,

When the EditText is focused, everything is okay, and I can see the hint above the EditText:

enter image description here

But when the EditText loses focus, the hint totally disappears:

enter image description here

I expect that the hint will return to the EditText, what am I missing?

xml code below.

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="20dp">

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Try me!"/>
    </android.support.design.widget.TextInputLayout>

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:hint="Try me 2"/>
</LinearLayout>
2

There are 2 answers

0
Billy On BEST ANSWER

This issue is fixed as of 22.2.1, update your Android SDK.

0
Ivan Yulin On

my SDK is updated so the accepted answer didnt work for me.

the fix in my case was to set a custom style OR to override some props:

give color values to android:textColorHint, app:boxStrokeColor and app:hintTextColor

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/input_layout"
    style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Edit Text"
    android:textColorHint="@color/some_color"
    app:boxStrokeColor="@color/some_color"
    app:hintTextColor="@color/some_color"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/input_edit_text"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</com.google.android.material.textfield.TextInputLayout>