Can anyone explain the differences between the
android:inputType="textPassword",
android:inputType="textVisiblePassword",
android:inputType="textWebPassword",
android:inputType="numberPassword"
of EditText ViewGroup in Android Layout?
Even though it has been already answered I'll add some more details to the differences in password InputType variations:
android:inputType="textPassword"
: Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD
i.e. it allows you to enter a string that is taken as a password (hidden and preventing autocompletion and suggestions unless set explicitly). This one is mostly used when we want to enter passwords.android:inputType="textVisiblePassword"
: Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
and is the same as the previous one but the password is visible (useful if you want to use it to allow to see the password as default because it prevents the autocompletion and suggestions unless they are set explicitly - it is advisable to also have a way to hide the password)android:inputType="numberPassword"
: Corresponds toTYPE_CLASS_NUMBER | TYPE_NUMBER_VARIATION_PASSWORD
same asandroid:inputType="textPassword"
but you can only enter numbers. Take into account that if you use it the password will not be so strong, so I wouldn't recommend using it when dealing with sensitive data unless it is used along with another type of user authentication.android:inputType="textWebPassword"
: Corresponds toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_WEB_PASSWORD
and has the same behaviour asandroid:inputType="textPassword"
but it is intended to be used in a web form i.e. inside a browser page (any web form control that takes input from a user). So this shall not be used in anEditText
native control. An example of using this would be to disable AutoSuggestion from Android in a WebView by wrapping aWebView
and changingEditorInfo
input type to add the flagInputType.TYPE_TEXT_VARIATION_WEB_PASSWORD
inside theonCreateInputConnection
method.As an example of the last one taken from the link:
I hope it is clear now the differences and mainly between
android:inputType="textPassword"
andandroid:inputType="textWebPassword"
From the doc for
android:inputType
:The attribute above will take the password as a string.
The one above will make the password text visible.
And this one will take a numeric password only.