Search code examples
androidandroid-edittextandroid-softkeyboard

EditText opens wrong keyboard on some devices when setting inputType programmatically


We are setting the inputType of an EditText programmatically to either support decimal or non-decimal numbers:

editText.inputType = if (isDecimal) InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_FLAG_DECIMAL else InputType.TYPE_CLASS_NUMBER 

This works on most devices and opens the numeric keyboard either with or without the decimal separator. On some devices however it opens the alphanumeric keyboard instead, e.g. on a Moto G5 with 8.1.0 or Caterpillar S31 with Android 8.

How do we fix this, so that the numeric keyboard will always be opened?


Solution

  • Is by any chance Gboard Keyboard used on these phones?

    Then please go to the PlayStore and check for Updates!