問(wèn)題描述
剛剛注意到 android:password 已被棄用,我們應(yīng)該使用 android:inputType.通過(guò)在我的 xml 中設(shè)置來(lái)試驗(yàn)它
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"
確實(shí)是這樣的
android:password="true"
對(duì)于 EditText,但似乎如果我使用 android:inputType,android:hint 將不起作用.EditText 將為空白.使用 android:password 和 android:hint 時(shí)沒(méi)有這樣的問(wèn)題.我在這里遺漏了一些關(guān)于 android:inputType 的內(nèi)容嗎?
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?
推薦答案
剛剛偶然發(fā)現(xiàn)了答案.android:inputType="textPassword"
確實(shí)適用于 android:hint
,與 android:password
相同.唯一的區(qū)別是當(dāng)我使用 android:gravity="center"
時(shí),如果我使用的是 android:inputType
,提示將不會(huì)顯示.結(jié)案!
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!
這篇關(guān)于帶有 android:hint 的 Android EditText 密碼的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!