我正在为仅使用数字的平板电脑设备设置EditText,但是在数字的左侧会出现一个带有数学运算符和其他选项的额外键盘:
我的EditText的定义如下:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/text_container"
android:id="@+id/edit_text"
android:hint="123-4567890"
android:digits="0123456789"
android:inputType="number"
android:layout_centerHorizontal="true"
android:textSize="36sp"
android:gravity="center_horizontal"
android:maxLength="10"
android:imeOptions="actionDone"
>
</EditText>
如果将inputType设置为“ numberPassword”,则会得到所需的结果:
在inputType设置为“数字”的情况下在电话设备中运行应用程序,还会显示我想要的内容:
为什么在平板设备中显示额外的键盘部分?
如何获得EditText以仅在平板电脑中显示数字,就像使用电话设备一样,还是使用“ numberPassword” inputType选项一样?
干杯!
为什么在平板设备中显示额外的键盘部分?
因为这就是它的设计方式。
如何获得EditText以仅在平板电脑中显示数字,
你不能。如果需要特定的键布局,则需要自己实现。
还是,你为什么还要打扰?用户可以使用他想要的任何键盘,甚至可以使用物理键盘,因此无论如何您都应该始终过滤输入的内容。参见https://developer.android.com/reference/android/text/InputFilter