Android password visibility toggle not working with support library 25?

Cuculus picture Cuculus · Dec 29, 2016 · Viewed 22.5k times · Source

I have implemented a TextInputLayout with a password field in the usual way:

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

    <EditText
        android:id="@+id/returning_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/prompt_password"
        android:inputType="textPassword"
        android:maxLines="1"
        android:textSize="14sp" />

</android.support.design.widget.TextInputLayout>

This worked fine when using the Android support library up to version 24.0.2, but after switching to 25.0.1:

compile 'com.android.support:design:25.0.1'
compile 'com.android.support:support-v4:25.0.1'
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'com.android.support:support-vector-drawable:25.0.1'

I no longer see the password visibility toggle (a.k.a. "eye icon") in the widget. Changing to the latest version 25.1.0 does not fix this problem.

Is there anything that I missed and need to change in combination with the support library 25, or could this be an Android issue?

Answer

H.P. picture H.P. · Dec 29, 2016

Try it this way.

<android.support.design.widget.TextInputLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   app:passwordToggleEnabled="true">

<EditText
    android:id="@+id/returning_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="@string/prompt_password"
    android:inputType="textPassword"
    android:maxLines="1"
    android:textSize="14sp" />

</android.support.design.widget.TextInputLayout>

This might be helpful for you!!

The TextInputLayout password toggle is now disabled by default to avoid unnecessarily overwriting developer-specified end drawables. It may be manually enabled via the passwordToggleEnabled XML attribute.

Recent Support Library Revisions