4

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>
Bugs Happen
  • 2,169
  • 4
  • 33
  • 59
David
  • 37,109
  • 32
  • 120
  • 141
  • 1
    `TextInputLayout` is buggy (reported bugs), but I only suspect the hint color here. See https://stackoverflow.com/a/30591555/603270 – shkschneider Jun 15 '15 at 16:00
  • 1
    It's not the color issue, It's properly related to the reported bugs https://code.google.com/p/android/issues/detail?id=175228 – David Jun 15 '15 at 16:03

2 Answers2

5

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

Billy
  • 1,374
  • 1
  • 17
  • 25
2

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>
Ivan Yulin
  • 794
  • 7
  • 15