EditText view with keyboard number only

2020-01-30 22:38发布

I want a keyboard with ONLY visible numbers to an EditText view. Without any other character.

I have tested with all available inputs and don't work. I have searched a way to get a keyboard only with numbers but I have only seen references to:

android: inputType = "numberPassword"

But I want visible numbers in EditText. Someone can help me?

I want a keyboard like that: (numberPassword)

enter image description here

I have tried with:

android:digits="0123456789"
android:inputType="phone"

and

android:inputType="number"

and appears like that:

enter image description here

8条回答
男人必须洒脱
2楼-- · 2020-01-30 23:27

android:inputType="number" or android:inputType="phone". You can keep this. You will get the keyboard containing numbers. For further details on different types of keyboard, check this link.

I think it is possible only if you create your own soft keyboard. Or try this android:inputType="number|textVisiblePassword. But it still shows other characters. Besides you can keep android:digits="0123456789" to allow only numbers in your edittext. Or if you still want the same as in image, try combining two or more features with | separator and check your luck, but as per my knowledge you have to create your own keypad to get exactly like that..

查看更多
Deceive 欺骗
3楼-- · 2020-01-30 23:29

If you want to show just numbers without characters, put this line of code inside your xml file android:inputType="number". Below image shows the exact output

enter image description here

If you want to show a number keyboard which also shows characters, put android:inputType="phone" on your xml. Below shows the exact output.

with characters

And if you want to show a number keyboard that masks your input just like a password, put android:inputType="numberpassword". Below is the output.

enter image description here

I'm really sorry if I only post the links of the screenshot, I want to do a research on how to do really post images here but it might consume my time so here it is. I hope my post can help other people. Yes my answer is duplicate with other answers posted here but to save other people's time that they might need to run their code before seeing the output, my post might save you some time. Have a nice day everyone!

查看更多
登录 后发表回答