14

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?

Cuculus
  • 166
  • 1
  • 2
  • 10

4 Answers4

44

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

H.P.
  • 1,181
  • 1
  • 13
  • 26
  • Perfect answer, thanks! That fixed it straight away, and I'll keep an eye on that link the next time the library version is updated. – Cuculus Dec 29 '16 at 18:03
  • for remove password roboto default typeface use `android:typeface="normal"` –  Jul 08 '17 at 14:53
  • How to achieve the same functionality with support library 23.4.0 – HONy May 22 '18 at 12:20
  • Sometimes the icon maybe white, so add **app:passwordToggleTint="some color"** for visibility. – Reejesh PK Dec 10 '18 at 09:22
6

if you use Jetpack then

add these dependencies

implementation 'com.google.android.material:material:1.0.0'

and add app:passwordToggleEnabled="true" in xml and one more thing, use inputType= textPassword and if you use rather than this then toggle button won't be shown.

Instead of using

<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>

, you need to use

<com.google.android.material.textfield.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" />

</com.google.android.material.textfield.TextInputLayout>
Lilia
  • 462
  • 6
  • 22
indrajeet jyoti
  • 431
  • 6
  • 8
3

You don't need to add following:

app:passwordToggleEnabled="true"

just change your dependency to:

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

That's the same bug I faced too while updating dependency.

Edit:

Now

app:passwordToggleEnabled="true"

is working with,

compile 'com.android.support:design:25.3.0'
Shanky
  • 149
  • 7
1
<android.support.design.widget.TextInputLayout
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   app:passwordToggleEnabled="true">

app:passwordToggleEnabled="true">

<EditText
    android:id="@+id/edt_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Password"
    android:inputType="textPassword"
    android:maxLines="1"
    android:textSize="16sp" />

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

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'

Keshav Gera
  • 10,807
  • 1
  • 75
  • 53