how to toggle password visibility in android studio 3.6

122 Views Asked by At

I have tried to use the functionality to toggle password visibility in the android studio 3.6.3 but due to some new upgrades features I'm not able to toggle password visibility. So I need a help to attain this toggle option.

1

There are 1 best solutions below

0
On

I am not sure if what you are asking is how to toggle password visibility on a TextInputLayout, but this works for me.

Using TextInputLayout and TextInputLayout you can do it this way

<com.google.android.material.textfield.TextInputLayout
    android:id="@+id/layout_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="Password"
    app:passwordToggleEnabled="true">

    <com.google.android.material.textfield.TextInputEditText
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:backgroundTint="@color/lightGrey"
        android:freezesText="true"
        android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>

The important attribute is app:passwordToggleEnabled="true" at TextInputLayout.

I hope this may help.