Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Keyboard with number and decimal for LG G4

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"

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

The keyboard layout looks like below. Nexus keyboard Layout

The keyboard layout on the LG G4 looks like below.LG G4 keyboard Layout

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.

Thanks in advance.

like image 304
B.B. Avatar asked Jun 09 '16 09:06

B.B.


People also ask

How do I get symbols on my LG keyboard?

Tap Settings > General tab > Language & input > On-screen keyboard > LG Keyboard > Keyboard height and layout. Allows you to change voice input, handwriting and symbol keys, to the left and right of the space bar for quick access.

How do I get the LG keyboard back to normal?

Tap and hold the Numbers/Symbols Key . Tap Input language & type > Settings . Tap QWERTY keyboard, Phone keyboard, Handwriting, or Shape writer.


1 Answers

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

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);

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.

like image 192
pmellaaho Avatar answered Oct 17 '22 06:10

pmellaaho