本文介紹了android:inputType=“textPassword"、“textVisiblePassword"、“textWebPassword"之間的區別和“數字密碼"在安卓?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
誰能解釋一下兩者的區別
Can anyone explain the differences between the
Android Layout 中的 EditText ViewGroup?
of EditText ViewGroup in Android Layout?
推薦答案
即使已經回答了,我還是會在密碼差異方面添加更多細節InputType 變體:
Even though it has been already answered I'll add some more details to the differences in password InputType variations:
android:inputType="textPassword"
:對應TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_PASSWORD
即它允許您輸入一個作為密碼的字符串(隱藏并防止自動完成和建議,除非明確設置).這個主要用于我們要輸入密碼的時候.android:inputType="textVisiblePassword"
:對應TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
并且與前一個相同,但密碼是可見的(如果您想使用它來允許查看默認密碼,因為它會阻止自動完成和建議,除非它們被明確設置 - 這是可取的也有辦法隱藏密碼)android:inputType="numberPassword"
:對應TYPE_CLASS_NUMBER |TYPE_NUMBER_VARIATION_PASSWORD
與android:inputType="textPassword"
相同,但您只能輸入數字.考慮到如果你使用它,密碼不會那么強,所以我不建議在處理敏感數據時使用它,除非它與其他類型的用戶身份驗證一起使用.android:inputType="textWebPassword"
:對應TYPE_CLASS_TEXT |TYPE_TEXT_VARIATION_WEB_PASSWORD
并具有與android:inputType="textPassword"
相同的行為,但它旨在用于 Web 表單,即在瀏覽器頁面內(任何從用戶).所以這不應在EditText
本機控件中使用.使用此方法的示例是通過包裝WebView
在 WebView 中禁用 Android 的 AutoSuggestion并更改EditorInfo
輸入類型以在onCreateInputConnection
方法中添加標志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.
作為從鏈接中截取的最后一個示例:
As an example of the last one taken from the link:
我希望現在很清楚區別,主要是 android:inputType="textPassword"
和 android:inputType="textWebPassword"
I hope it is clear now the differences and mainly between android:inputType="textPassword"
and android:inputType="textWebPassword"
這篇關于android:inputType=“textPassword"、“textVisiblePassword"、“textWebPassword"之間的區別和“數字密碼"在安卓?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!