問題描述
誰能解釋一下兩者的區(qū)別
Can anyone explain the differences between the
Android Layout 中的 EditText ViewGroup?
of EditText ViewGroup in Android Layout?
推薦答案
即使已經(jīng)回答了,我還是會(huì)在密碼差異方面添加更多細(xì)節(jié)InputType 變體:
Even though it has been already answered I'll add some more details to the differences in password InputType variations:
android:inputType="textPassword"
:對應(yīng)TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_PASSWORD
即它允許您輸入一個(gè)作為密碼的字符串(隱藏并防止自動(dòng)完成和建議,除非明確設(shè)置).這個(gè)主要用于我們要輸入密碼的時(shí)候.android:inputType="textVisiblePassword"
:對應(yīng)TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
并且與前一個(gè)相同,但密碼是可見的(如果您想使用它來允許查看默認(rèn)密碼,因?yàn)樗鼤?huì)阻止自動(dòng)完成和建議,除非它們被明確設(shè)置 - 這是可取的也有辦法隱藏密碼)android:inputType="numberPassword"
:對應(yīng)TYPE_CLASS_NUMBER |TYPE_NUMBER_VARIATION_PASSWORD
與android:inputType="textPassword"
相同,但您只能輸入數(shù)字.考慮到如果你使用它,密碼不會(huì)那么強(qiáng),所以我不建議在處理敏感數(shù)據(jù)時(shí)使用它,除非它與其他類型的用戶身份驗(yàn)證一起使用.android:inputType="textWebPassword"
:對應(yīng)TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_WEB_PASSWORD
并具有與android:inputType="textPassword"
相同的行為,但它旨在用于 Web 表單,即在瀏覽器頁面內(nèi)(任何從用戶).所以這不應(yīng)在EditText
本機(jī)控件中使用.使用此方法的示例是通過包裝WebView
在 WebView 中禁用 Android 的 AutoSuggestion并更改EditorInfo
輸入類型以在onCreateInputConnection
方法中添加標(biāo)志InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD
.
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.
作為從鏈接中截取的最后一個(gè)示例:
As an example of the last one taken from the link:
我希望現(xiàn)在很清楚區(qū)別,主要是 android:inputType="textPassword"
和 android:inputType="textWebPassword"
I hope it is clear now the differences and mainly between android:inputType="textPassword"
and android:inputType="textWebPassword"
這篇關(guān)于android:inputType=“textPassword"、“textVisiblePassword"、“textWebPassword"之間的區(qū)別和“數(shù)字密碼"在安卓?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!