带有 android:hint 的 Android EditText 密码 [英] Android EditText for password with android:hint

查看:19
本文介绍了带有 android:hint 的 Android EditText 密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚注意到 android:password 已被弃用,我们应该使用 android:inputType.通过在我的 xml 中设置来试验它

Just noticed that android:password has been deprecated, and we should be using android:inputType. Was experimenting with it by setting in my xml

android:inputType="textPassword" 

确实是这样的

android:password="true" 

对于 EditText,但似乎如果我使用 android:inputType,android:hint 将不起作用.EditText 将为空白.使用 android:password 和 android:hint 时没有这样的问题.我在这里遗漏了一些关于 android:inputType 的内容吗?

for EditText, but it seems that if I use android:inputType, android:hint will not work. The EditText will be blank. There is no such issues when using android:password with android:hint. Am I missing something here about android:inputType?

推荐答案

刚刚偶然发现了答案.android:inputType="textPassword" 确实适用于 android:hint,与 android:password 相同.唯一的区别是当我使用 android:gravity="center" 时,如果我使用的是 android:inputType,提示将不会显示.结案!

Just stumbled on the answer. android:inputType="textPassword" does work with android:hint, same as android:password. The only difference is when I use android:gravity="center", the hint will not show if I'm using android:inputType. Case closed!

这篇关于带有 android:hint 的 Android EditText 密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆