Keyboard
open classKeyboard
| 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 | |
|---|---|
|
Creates a keyboard from the given xml key layout file. |
|
|
Creates a keyboard from the given xml key layout file. |
|
|
Creates a keyboard from the given xml key layout file. |
|
<init>(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!>! |
getKeys() |
| open Int | |
| open MutableList<Keyboard.Key!>! | |
| open IntArray! |
getNearestKeys(x: Int, y: Int)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! |
createRowFromXml(res: Resources!, parser: XmlResourceParser!) |
| open Int | |
| open Int | |
| open Int | |
| open Int | |
| open Unit |
setHorizontalGap(gap: Int) |
| open Unit |
setKeyHeight(height: Int) |
| open Unit |
setKeyWidth(width: Int) |
| open Unit |
setVerticalGap(gap: Int) |
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
Public constructors
<init>
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. |
<init>
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 |
<init>
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 |
<init>
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
open fungetHeight(): Int
Deprecated.
Returns the total height of the keyboard
| Return | |
|---|---|
Int |
the total height of the keyboard |
getNearestKeys
open fungetNearestKeys(
x: Int,
y: Int
): IntArray!
Deprecated.
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. |
Protected methods
createKeyFromXml
protected open funcreateKeyFromXml(
res: Resources!,
parent: Keyboard.Row!,
x: Int,
y: Int,
parser: XmlResourceParser!
): Keyboard.Key!
Deprecated.
createRowFromXml
protected open funcreateRowFromXml(
res: Resources!,
parser: XmlResourceParser!
): Keyboard.Row!
Deprecated.