简体   繁体   English

Android EditText 大写字母数字键盘

[英]Android EditText upper case alphanumeric keyboard

I have an EditText and it should display alphanumeric keyboard (both letters and numbers visible on keyboard).我有一个 EditText,它应该显示字母数字键盘(字母和数字都在键盘上可见)。 Letters must be upper case.字母必须大写。 What attributes should I set for EditText?我应该为 EditText 设置哪些属性? I tried:我试过:

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textVisiblePassword"
    android:textAllCaps="true" />

This shows lower case alphanumeric keyboard.这显示了小写字母数字键盘。

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textCapCharacters"
    android:textAllCaps="true" />

And this shows upper case keyboard but without numbers.这显示大写键盘但没有数字。

I need a keyboard like this:我需要这样的键盘: 在此处输入图片说明

Both numbers and upper case letters visible on default layout (without the need to switch CAPS on, or in other words with CAPS turned on in default).数字和大写字母都在默认布局中可见(无需打开大写字母,或者换句话说,默认情况下大写字母打开)。

try inputType = textVisiblePassword|textCapCharacters尝试 inputType = textVisiblePassword|textCapCharacters

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textVisiblePassword|textCapCharacters" />

When you have android:inputType="textCapCharacters" , you will have alphanumeric keyboard as you see in these pictures:当您有android:inputType="textCapCharacters" ,您将拥有字母数字键盘,如以下图片所示:

在此处输入图片说明 在此处输入图片说明

You can change keyboard style in settings of your phone.您可以在手机设置中更改键盘样式。 User can also set keyboard so that it is invisible at all.用户还可以将键盘设置为完全不可见。 But you can make custom keyboard.但是您可以制作自定义键盘。 This question may help you: How can you make a custom keyboard in Android?这个问题可能对您帮助:如何在 Android 中制作自定义键盘?

You can android:digits property to restrict other text您可以 android:digits 属性来限制其他文本

android:inputType="textCapCharacters"
android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 "

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM