Keyboard Type is a virtual keyboard configuration in Android that defines the set of displayed characters and layout for a specific input field. Android supports many preset types: text (standard text), number (numeric), phone (telephone), email (with @ symbol), textPassword (for passwords), datetime, and others. Each type optimizes the input interface for a specific task — for example, the email keyboard shows the @ symbol and dot on the main screen. According to Android Developers (2026), choosing the right Keyboard Type reduces the number of keystrokes by 20–40% compared to a standard text keyboard.
Key Takeaways
Keyboard Type is determined by the android:inputType attribute value in XML or by a programmatic call to setInputType() in code. InputType is a bitmask where the input class is combined with modifier flags. The base classes are: TYPE_CLASS_TEXT for text, TYPE_CLASS_NUMBER for numbers, TYPE_CLASS_PHONE for phones, TYPE_CLASS_DATETIME for dates and times.
Each Keyboard Type affects three aspects: the virtual keyboard layout (which characters are visible on the main screen), the filtering of entered characters (which characters are allowed), and the autocorrect/autocomplete behavior. For example, the number keyboard displays only digits and the decimal separator, and it does not show letters even if the user switches case. According to Android Developers Documentation (2026), combining classes with flags allows creating highly specialized modes: multiline text with autocorrect, floating-point number, password with autofill support.
It is important to understand that Keyboard Type is a recommendation to the input system (IME). Some third-party keyboards (Gboard, SwiftKey) may partially ignore the specified type if the user has set their own preferences. However, most standard Android keyboards and Google Gboard strictly follow the specified input type.
// Programmatic keyboard type setup
editText.inputType = InputType.TYPE_CLASS_NUMBER or
InputType.TYPE_NUMBER_FLAG_DECIMAL or
InputType.TYPE_NUMBER_FLAG_SIGNED
TYPE_CLASS_TEXT is the base class for text input. It activates the standard QWERTY keyboard with letters, digits, and symbols. The text class has the most modifiers that refine behavior: TYPE_TEXT_FLAG_CAP_SENTENCES (automatic capital letter at the beginning of a sentence), TYPE_TEXT_FLAG_AUTO_CORRECT (autocorrect), TYPE_TEXT_FLAG_MULTI_LINE (multiline mode), TYPE_TEXT_FLAG_NO_SUGGESTIONS (disable suggestions).
Text keyboard modifiers can be combined to create precise configurations: for example, text|textCapSentences|textAutoCorrect is suitable for a comment input field where automatic capitalization and typo correction are needed. Meanwhile, text|textNoSuggestions is used for entering code or special terms where autocorrect can be harmful.
According to UX Stack Exchange (2025), a text keyboard with autocorrect enabled speeds up typing by 15–25% for the average user, but for technical terms (code, URL, email) it is recommended to disable autocorrect as it often replaces correct terms with incorrect ones.
<!-- Text with autocorrect and capital sentences -->
android:inputType="textCapSentences|textAutoCorrect"
<!-- Text without suggestions and autocorrect -->
android:inputType="textNoSuggestions"
TYPE_CLASS_NUMBER activates the numeric keyboard, which displays only digits, the decimal separator, and the minus sign. This type is used for quantity input fields, prices, age, codes, and other numeric data. The numeric keyboard takes up less screen space than a text keyboard and eliminates accidental letter input.
Number has three modifiers: TYPE_NUMBER_FLAG_DECIMAL adds a decimal point/comma, TYPE_NUMBER_FLAG_SIGNED adds a minus sign for negative numbers, TYPE_NUMBER_VARIATION_PASSWORD — for PIN codes where digits are displayed as hidden characters. The combination number|numberDecimal|numberSigned creates a full-featured field for entering floating-point numbers of any sign.
// Numeric input with decimal point
editText.inputType = InputType.TYPE_CLASS_NUMBER or
InputType.TYPE_NUMBER_FLAG_DECIMAL
// Check entered number
val amount = editText.text.toString().toDoubleOrNull() ?: 0.0
TYPE_CLASS_PHONE activates the phone keyboard, which displays digits and characters typical for phone numbers: +, #, *, (, ). Unlike the number keyboard, phone also shows a letter layout in an additional mode, since phone numbers can contain letters (e.g., 1-800-FLOWERS). The phone class has no additional flags but supports TYPE_TEXT_VARIATION_PHONE_ETC for entering extensions.
TYPE_TEXT_VARIATION_EMAIL_ADDRESS activates the email keyboard, where the @ symbol and dot are on the main screen, and common domain extensions (.com, .net, .org) are also available. Gboard additionally shows buttons with popular domains when typing after @. The email keyboard automatically disables autocorrect since email addresses can contain non-standard character combinations.
According to Google Material Design Guidelines (2025), for phone fields it is additionally recommended to specify the android:digits attribute, which limits the set of allowed characters. For email fields, it is also important to specify autofillHints="email" to support autofill from password managers and Google Autofill.
<!-- Email keyboard with autofill -->
android:inputType="textEmailAddress"
android:importantForAutofill="yes"
android:autofillHints="emailAddress"
<!-- Phone keyboard with digit restriction -->
android:inputType="phone"
android:digits="0123456789+"
TYPE_TEXT_VARIATION_PASSWORD and TYPE_NUMBER_VARIATION_PASSWORD are input modes for sensitive data. When textPassword is set, entered characters are displayed as dots or asterisks (depending on the Android version and keyboard). The keyboard in this mode disables autocorrect and saving entered words to the user dictionary, preventing password leakage through predictive input features.
The Password keyboard also disables the ability to take screenshots of the field content (FLAG_SECURE flag), although this behavior depends on the specific keyboard implementation. Starting with Android 8.0 (API 26), password keyboards support autofill through password managers if the importantForAutofill="yes" attribute is set.
According to Android Security Recommendations (2025), for password fields it is also recommended to: set maxLength to prevent very long passwords (which could be a database attack vector), use inputType="textPassword" together with TextInputLayout and endIconMode="password_toggle" so the user can check the entered password before submitting the form.
<!-- Password field with show/hide icon -->
@+id/tilPasswordField
app:endIconMode="password_toggle">
@+id/etPasswordField
android:inputType="textPassword"
android:maxLength="64"
android:importantForAutofill="yes" />
</com.google.android.material.textfield.TextInputLayout>
Programmatic setup of Keyboard Type allows dynamically changing the keyboard mode depending on context or user input. For example, when switching the field type (text/number/date) or when changing the locale. The setInputType() method accepts an InputType bitmask and immediately updates the keyboard if the field is in focus.
// Switch between text and numeric input
fun switchInputType(field: EditText, isNumeric: Boolean) {
field.inputType = if (isNumeric) {
InputType.TYPE_CLASS_NUMBER or
InputType.TYPE_NUMBER_FLAG_DECIMAL
} else {
InputType.TYPE_CLASS_TEXT or
InputType.TYPE_TEXT_FLAG_CAP_SENTENCES
}
field.setSelection(field.text.length)
}
// Check if field is numeric
fun isNumericInput(field: EditText): Boolean {
val type = field.inputType
return (type and InputType.TYPE_MASK_CLASS) ==
InputType.TYPE_CLASS_NUMBER
}
// Check if autocorrect is enabled
fun isAutoCorrectEnabled(field: EditText): Boolean {
return (field.inputType and
InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) != 0
}
Frequently Asked Questions
If inputType is not specified, EditText by default uses TYPE_CLASS_TEXT with the TYPE_TEXT_FLAG_MULTI_LINE flag. This means a standard QWERTY keyboard and multiline input. For most fields, it is recommended to explicitly specify inputType to ensure correct keyboard behavior and character filtering.
Use the android:imeOptions="actionDone" attribute on EditText. This will replace the Enter button with a Done button. Other options: actionSearch (magnifying glass), actionNext (right arrow), actionSend (send). Handle the press via OnEditorActionListener in code.
You cannot disable vibration for a specific field — it is a system setting controlled by the user in keyboard settings. However, you can prevent the keyboard from appearing entirely by setting the android:focusable="false" attribute on EditText or by overriding the show via dispatchTouchEvent.
Set android:inputType="none" or programmatically call editText.setKeyListener(null). The field will display text, but the keyboard will not appear on focus. The user will be able to select and copy text, but not edit it. An alternative is to use TextView with textIsSelectable="true".
After calling setInputType(), you need to show the keyboard again, as the system may not update the IME automatically. Call InputMethodManager.restartInput(view) to force an update. If the field is not focused, first call requestFocus(), then restartInput.
Summary
We will develop a mobile application turnkey
IT Sectr creates iOS and Android applications for startups and businesses since 2017. We will advise you and propose the best solution.
Read also