LG G4带有数字和小数的Android键盘 [英] Android Keyboard with number and decimal for LG G4

查看:100
本文介绍了LG G4带有数字和小数的Android键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android EditText 中使用以下元素,以使键盘具有数字和小数,以显示金额输入的键盘布局(例如, 22.12 ).

I am using the following element in the Android EditText, to have a keyboard with number and decimal for displaying a keyboard layout for amount input (for eg 22.12).

android:inputType="numberDecimal"

它适用于所有设备,例如三星,Nexus,索尼等.

It is working for all devices, like Samsung, Nexus, Sony etc.

键盘布局如下所示.

The keyboard layout looks like below.

LG G4的键盘布局如下所示.

The keyboard layout on the LG G4 looks like below.

任何人都可以帮忙,如何为LG G4安装十进制键盘.我已经尝试过android:inputType="phone",仍然是同样的问题.

Could anyone please help, how to have decimal keyboard for the LG G4. I have already tried the android:inputType="phone", still same issue.

我想坚持使用十进制输入,因为拥有完整的字母数字键盘输入金额并不是很好.

I would like to stick to the decimal input, as it would not be very nice to have a full alpha-numeric keyboard, to enter amount.

谢谢.

推荐答案

更新 似乎完全不需要带符号的标志来获取小数点分隔符,实际上是TYPE_TEXT_FLAG_NO_SUGGESTIONS弄乱了键盘,因此请勿将其与数字输入类型一起使用.还注意到LG键盘的外观有所不同,具体取决于您是通过代码还是XML设置输入类型 END UPDATE

UPDATE It seems that flag signed is not needed after all to get decimal separator, It was actually the TYPE_TEXT_FLAG_NO_SUGGESTIONS that messed up the keyboard so do not use it with number input types. Also noticed that LG keyboard looks different depending on if you set the input type from code vs. XML END UPDATE

似乎inputType和digits的组合解决了这个问题.我有一个扩展EditText的类,所以我像这样初始化EditText:

It seems like the combination of inputType and digits solves the problem. I have a class that extends EditText so I initialize the EditText like this:

setKeyListener(DigitsKeyListener.getInstance("0123456789.,"));
setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED);

我想是因为LG在同一个按钮中捆绑了十进制分隔符和减号,所以您必须同时配置这两个功能,然后通过不包含数字来禁用-".

I guess that because LG has bundled decimal separator and minus sign in a same button you have to configure both feature on and then disable "-" by not including it in digits.

这篇关于LG G4带有数字和小数的Android键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆