Difference between android:inputType=quot;textPasswordquot;, quot;textVisiblePasswordquot;,quot;textWebPasswordquot; and quot;numberPasswordquot; in android?(android:inputType=“textPassword、“textVisiblePassword、“textWebPassword之间的区别和“数字密码在安卓?) - IT屋-程序员软件
问题描述
谁能解释一下两者的区别
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 toTYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORDi.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_PASSWORDand 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_PASSWORDsame 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_PASSWORDand 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 anEditTextnative control. An example of using this would be to disable AutoSuggestion from Android in a WebView by wrapping aWebViewand changingEditorInfoinput type to add the flagInputType.TYPE_TEXT_VARIATION_WEB_PASSWORDinside theonCreateInputConnectionmethod.
作为从链接中截取的最后一个示例:
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"之间的区别和“数字密码"在安卓?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:android:inputType=“textPassword"、“textVisiblePassw
基础教程推荐
- 我的 UIImageView 的任务 2022-01-01
- 突出显示朗读文本(在 iPhone 的故事书类型应用程序中) 2022-01-01
- 在 appComponent dagger 2 中动态添加测试模块? 2022-01-01
- 新的@SystemApi 注解是什么意思,和@hide 有什么区别 2022-01-01
- 如何将多个组件添加到 PickerView? 2022-01-01
- 可可/目标C(OSX不是iOS)从子对象访问父对象 2022-01-01
- 在 iOS8 中无法获得正确的键盘高度值 2022-01-01
- - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view 如何工作 2022-01-01
- 在 Android 模拟器中激活网络位置提供程序? 2022-01-01
- Android:STATE_SELECTED不工作 2022-01-01
