Android numeric password field

2019-01-13 13:06发布

I have an EditText field which needs to be a numeric password field. Everything works OK in portrait mode; not in landscape. When the user selects the EditText field, the UI zooms into the field and when I type all the characters are visible.

I need a numeric keyboard also. I tried setting the input type to text password|number. If I remove "number" option everything works right; otherwise no.

Any suggestions?

8条回答
迷人小祖宗
2楼-- · 2019-01-13 13:41

To fix the issue where the password is visible in the landscape mode full-screen editor (as Marcus described), you can add the following line to disable the full-screen editor:

editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);

You may also want to change the typeface to monospace to better emulate the text-password behavior:

editText.setTypeface(Typeface.MONOSPACE);
查看更多
别忘想泡老子
3楼-- · 2019-01-13 13:43

This how to make input password that has hint which not converted to * !!.

On XML :

android:inputType="textPassword"
android:gravity="center"
android:ellipsize="start"
android:hint="Input Password !."

thanks to : mango and rjrjr for the insight :D.

查看更多
登录 后发表回答