Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove show password icon in Android N

New Android version automatically draws show password icon when I set android:inputType="textPassword" in EditText view. How can I disable it? Thanks

enter image description here

like image 555
elementstyle Avatar asked Aug 18 '16 13:08

elementstyle


People also ask

How do I change my hide and view password?

setTransformationMethod(new PasswordTransformationMethod()); to hide the password. To show the password you could set one of the existing transformation methods or implement an empty TransformationMethod that does nothing with the input text. To show the password, you don't need to make any new classes.

What is TextInputLayout?

TextInputLayout is a view container that is used to add more features to an EditText. It acts as a wrapper for EditText and has some features like: Floating hint. Animation that can be disabled or enabled. Error labels that display error messages when an error occurs.


1 Answers

The password icon (or eye-icon) use be removed with the method setPasswordVisibilityToggleEnabled or with app:passwordToggleEnabled through XML.

For more information see support library revisions.

Example:

<android.support.design.widget.TextInputLayout     android:id="@+id/new_password_layout"     android:layout_width="match_parent"     android:layout_height="wrap_content"     app:errorEnabled="true"     app:passwordToggleEnabled="false">      <EditText         android:id="@+id/password_edit"         android:layout_width="match_parent"         android:layout_height="wrap_content"         android:hint="@string/new_password"         android:imeOptions="actionNext"         android:inputType="textPassword"         android:singleLine="true"/>  </android.support.design.widget.TextInputLayout> 
like image 85
Cremons Avatar answered Oct 16 '22 02:10

Cremons