Added in API level 3
Deprecated in API level 29

Keyboard


open class Keyboard
kotlin.Any
   ↳ android.inputmethodservice.Keyboard

Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard consists of rows of keys.

The layout file for a keyboard contains XML that looks like the following snippet:

<Keyboard
          android:keyWidth="%10p"
          android:keyHeight="50px"
          android:horizontalGap="2px"
          android:verticalGap="2px" >
      <Row android:keyWidth="32px" >
          <Key android:keyLabel="A" />
          ...
      </Row>
      ...
  </Keyboard>
  

Summary

Nested classes
open

Class for describing the position and characteristics of a single key in the keyboard.

open

Container for keys in the keyboard.

XML attributes
android:horizontalGap Default horizontal gap between keys.
android:keyHeight Default height of a key, in pixels or percentage of display width.
android:keyWidth Default width of a key, in pixels or percentage of display width.
android:verticalGap Default vertical gap between rows of keys.
Constants
static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

static Int

Public constructors
Keyboard(context: Context!, xmlLayoutResId: Int)

Creates a keyboard from the given xml key layout file.

Keyboard(context: Context!, xmlLayoutResId: Int, modeId: Int, width: Int, height: Int)

Creates a keyboard from the given xml key layout file.

Keyboard(context: Context!, xmlLayoutResId: Int, modeId: Int)

Creates a keyboard from the given xml key layout file.

Keyboard(context: Context!, layoutTemplateResId: Int, characters: CharSequence!, columns: Int, horizontalPadding: Int)

Creates a blank keyboard from the given resource file and populates it with the specified characters in left-to-right, top-to-bottom fashion, using the specified number of columns.

Public methods
open Int

Returns the total height of the keyboard

open MutableList<Keyboard.Key!>!

open Int

open MutableList<Keyboard.Key!>!

open IntArray!

Returns the indices of the keys that are closest to the given point.

open Int

open Boolean

open Boolean
setShifted(shiftState: Boolean)

Protected methods
open Keyboard.Key!
createKeyFromXml(res: Resources!, parent: Keyboard.Row!, x: Int, y: Int, parser: XmlResourceParser!)

open Keyboard.Row!

open Int

open Int

open Int

open Int

open Unit

open Unit
setKeyHeight(height: Int)

open Unit
setKeyWidth(width: Int)

open Unit

XML attributes

android:horizontalGap

android:horizontalGap
Default horizontal gap between keys. {@deprecated Copy this definition into your own application project.}

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

May be a fractional value, which is a floating point number appended with either % or %p, such as "14.5%". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.

android:keyHeight

android:keyHeight
Default height of a key, in pixels or percentage of display width. {@deprecated Copy this definition into your own application project.}

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

May be a fractional value, which is a floating point number appended with either % or %p, such as "14.5%". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.

android:keyWidth

android:keyWidth
Default width of a key, in pixels or percentage of display width. {@deprecated Copy this definition into your own application project.}

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

May be a fractional value, which is a floating point number appended with either % or %p, such as "14.5%". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.

android:verticalGap

android:verticalGap
Default vertical gap between rows of keys. {@deprecated Copy this definition into your own application project.}

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

May be a fractional value, which is a floating point number appended with either % or %p, such as "14.5%". The % suffix always means a percentage of the base size; the optional %p suffix provides a size relative to some parent container.

Constants

EDGE_BOTTOM

Added in API level 3
static val EDGE_BOTTOM: Int

Deprecated: Deprecated in Java.

Value: 8

EDGE_LEFT

Added in API level 3
static val EDGE_LEFT: Int

Deprecated: Deprecated in Java.

Value: 1

EDGE_RIGHT

Added in API level 3
static val EDGE_RIGHT: Int

Deprecated: Deprecated in Java.

Value: 2

EDGE_TOP

Added in API level 3
static val EDGE_TOP: Int

Deprecated: Deprecated in Java.

Value: 4

KEYCODE_ALT

Added in API level 3
static val KEYCODE_ALT: Int

Deprecated: Deprecated in Java.

Value: -6

KEYCODE_CANCEL

Added in API level 3
static val KEYCODE_CANCEL: Int

Deprecated: Deprecated in Java.

Value: -3

KEYCODE_DELETE

Added in API level 3
static val KEYCODE_DELETE: Int

Deprecated: Deprecated in Java.

Value: -5

KEYCODE_DONE

Added in API level 3
static val KEYCODE_DONE: Int

Deprecated: Deprecated in Java.

Value: -4

KEYCODE_MODE_CHANGE

Added in API level 3
static val KEYCODE_MODE_CHANGE: Int

Deprecated: Deprecated in Java.

Value: -2

KEYCODE_SHIFT

Added in API level 3
static val KEYCODE_SHIFT: Int

Deprecated: Deprecated in Java.

Value: -1

Public constructors

Keyboard

Added in API level 3
Keyboard(
    context: Context!,
    xmlLayoutResId: Int)

Creates a keyboard from the given xml key layout file.

Parameters
context Context!: the application or service context
xmlLayoutResId Int: the resource file that contains the keyboard layout and keys.

Keyboard

Added in API level 11
Keyboard(
    context: Context!,
    xmlLayoutResId: Int,
    modeId: Int,
    width: Int,
    height: Int)

Creates a keyboard from the given xml key layout file. Weeds out rows that have a keyboard mode defined but don't match the specified mode.

Parameters
context Context!: the application or service context
xmlLayoutResId Int: the resource file that contains the keyboard layout and keys.
modeId Int: keyboard mode identifier
width Int: sets width of keyboard
height Int: sets height of keyboard

Keyboard

Added in API level 3
Keyboard(
    context: Context!,
    xmlLayoutResId: Int,
    modeId: Int)

Creates a keyboard from the given xml key layout file. Weeds out rows that have a keyboard mode defined but don't match the specified mode.

Parameters
context Context!: the application or service context
xmlLayoutResId Int: the resource file that contains the keyboard layout and keys.
modeId Int: keyboard mode identifier

Keyboard

Added in API level 3
Keyboard(
    context: Context!,
    layoutTemplateResId: Int,
    characters: CharSequence!,
    columns: Int,
    horizontalPadding: Int)

Creates a blank keyboard from the given resource file and populates it with the specified characters in left-to-right, top-to-bottom fashion, using the specified number of columns.

If the specified number of columns is -1, then the keyboard will fit as many keys as possible in each row.

Parameters
context Context!: the application or service context
layoutTemplateResId Int: the layout template file, containing no keys.
characters CharSequence!: the list of characters to display on the keyboard. One key will be created for each character.
columns Int: the number of columns of keys to display. If this number is greater than the number of keys that can fit in a row, it will be ignored. If this number is -1, the keyboard will fit as many keys as possible in each row.

Public methods

getHeight

Added in API level 3
open fun getHeight(): Int

Deprecated: Deprecated in Java.

Returns the total height of the keyboard

Return
Int the total height of the keyboard

getKeys

Added in API level 3
open fun getKeys(): MutableList<Keyboard.Key!>!

Deprecated: Deprecated in Java.

getMinWidth

Added in API level 3
open fun getMinWidth(): Int

Deprecated: Deprecated in Java.

getModifierKeys

Added in API level 3
open fun getModifierKeys(): MutableList<Keyboard.Key!>!

Deprecated: Deprecated in Java.

getNearestKeys

Added in API level 3
open fun getNearestKeys(
    x: Int,
    y: Int
): IntArray!

Deprecated: Deprecated in Java.

Returns the indices of the keys that are closest to the given point.

Parameters
x Int: the x-coordinate of the point
y Int: the y-coordinate of the point
Return
IntArray! the array of integer indices for the nearest keys to the given point. If the given point is out of range, then an array of size zero is returned.

getShiftKeyIndex

Added in API level 3
open fun getShiftKeyIndex(): Int

Deprecated: Deprecated in Java.

isShifted

Added in API level 3
open fun isShifted(): Boolean

Deprecated: Deprecated in Java.

setShifted

Added in API level 3
open fun setShifted(shiftState: Boolean): Boolean

Deprecated: Deprecated in Java.

Protected methods

createKeyFromXml

Added in API level 3
protected open fun createKeyFromXml(
    res: Resources!,
    parent: Keyboard.Row!,
    x: Int,
    y: Int,
    parser: XmlResourceParser!
): Keyboard.Key!

Deprecated: Deprecated in Java.

createRowFromXml

Added in API level 3
protected open fun createRowFromXml(
    res: Resources!,
    parser: XmlResourceParser!
): Keyboard.Row!

Deprecated: Deprecated in Java.

getHorizontalGap

Added in API level 3
protected open fun getHorizontalGap(): Int

Deprecated: Deprecated in Java.

getKeyHeight

Added in API level 3
protected open fun getKeyHeight(): Int

Deprecated: Deprecated in Java.

getKeyWidth

Added in API level 3
protected open fun getKeyWidth(): Int

Deprecated: Deprecated in Java.

getVerticalGap

Added in API level 3
protected open fun getVerticalGap(): Int

Deprecated: Deprecated in Java.

setHorizontalGap

Added in API level 3
protected open fun setHorizontalGap(gap: Int): Unit

Deprecated: Deprecated in Java.

setKeyHeight

Added in API level 3
protected open fun setKeyHeight(height: Int): Unit

Deprecated: Deprecated in Java.

setKeyWidth

Added in API level 3
protected open fun setKeyWidth(width: Int): Unit

Deprecated: Deprecated in Java.

setVerticalGap

Added in API level 3
protected open fun setVerticalGap(gap: Int): Unit

Deprecated: Deprecated in Java.