Search code examples
androidandroid-edittextandroid-appcompatandroid-textinputlayout

TextInputLayout and EditText double hint issue


I want to set the hint with java in EditText(which is in TextInputLayout).

Code used for setting hint:

aET = (EditText) findViewById(R.id.aET); aET.setHint("h?");

But even when edittext is focused, Hint is displayed twice(inside edittext also).

Please let me know if anyone had faced and found some workaround

when editText is focused...

Second

when editText is not focused..

First

EDIT[10th July 2015]:

<android.support.design.widget.TextInputLayout
     android:id="@+id/aTIL"
     android:layout_width="match_parent"
     android:layout_height="wrap_content">
     <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/aET" />
</android.support.design.widget.TextInputLayout>

Solution

  • I found the solution !

    In your EditText add

    android:textColorHint="@android:color/transparent"
    

    And in the code set the hint from the EditText

    aET.setHint("h?");
    

    The hint in your editText is hidden and the hint from the TextInputLayout is shown.

    EDIT :

    Other solution (The best)

    Update Graddle with the new version of android:design

    compile 'com.android.support:design:22.2.1'