问题
I have an application that requires that the user enter an ASCII password between dec 32 and 126. This means that only a latin character and number keyboard is valid for editing. However, when I launch my edittext, a cyrillic keyboard is presented to the user.
My question is, how do I ensure that only a latin keyboard is presented to the user?
回答1:
There is no way to force IME to a certain language/character set. However, if you set your EditText to be type password, most software keyboards will limit itself to ASCII + number. That's the closest you will get without writing your own input method.
<EditText
android:password="true"
...
/>
回答2:
Try to add this to your xml:
<EditText
android:inputType="text"
android:digits="0,1,2,3,4,5,6,7,8,9,*,qwertzuiopasdfghjklyxcvbnm" />
来源:https://stackoverflow.com/questions/30630597/how-do-i-restrict-the-android-keyboard-presented-to-a-user-to-latin