谁能解释一下两者的区别
Can anyone explain the differences between the
android:inputType="textPassword",
android:inputType="textVisiblePassword",
android:inputType="textWebPassword",
android:inputType="numberPassword"
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 to TYPE_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 to TYPE_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 to TYPE_CLASS_NUMBER | TYPE_NUMBER_VARIATION_PASSWORD same as android: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 to TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_WEB_PASSWORD and has the same behaviour as android: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 an EditText native control. An example of using this would be to disable AutoSuggestion from Android in a WebView by wrapping a WebView and changing EditorInfo input type to add the flag InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD inside the onCreateInputConnectionmethod.作为从链接中截取的最后一个示例:
As an example of the last one taken from the link:
public class NoSuggestionsWebView extends WebView {
...
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs)
{
InputConnection ic = super.onCreateInputConnection(outAttrs);
outAttrs.inputType &= ~EditorInfo.TYPE_MASK_VARIATION; /* clear VARIATION type to be able to set new value */
outAttrs.inputType |= InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD; /* WEB_PASSWORD type will prevent form suggestions */
return ic;
}
}
我希望现在很清楚区别,主要是 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模板网!
在android中剪切、复制、粘贴Cut, copy, paste in android(在android中剪切、复制、粘贴)
android EditText 融入背景android EditText blends into background(android EditText 融入背景)
更改 EditText 的线条颜色 - AndroidChange Line Color of EditText - Android(更改 EditText 的线条颜色 - Android)
EditText 始终显示带 2 位小数的数字EditText showing numbers with 2 decimals at all times(EditText 始终显示带 2 位小数的数字)
更改光标在展开的 EditText 中的开始位置Changing where cursor starts in an expanded EditText(更改光标在展开的 EditText 中的开始位置)
android中的EditText,adjustPan,ScrollView问题EditText, adjustPan, ScrollView issue in android(android中的EditText,adjustPan,ScrollView问题)