# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Nested Classes | XML Attrs | Constants | Ctors | Methods | Protected Methods | Inherited Methods

# Keyboard

`public class Keyboard`
`extends Object` ``

java.lang.Object
↳ | android.inputmethodservice.Keyboard

This class is deprecated.
This class is deprecated because this is just a convenient UI widget class that application developers can re-implement on top of existing public APIs. If you have already depended on this class, consider copying the implementation from AOSP into your project or re-implementing a similar widget by yourselves

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
`class` | `Keyboard.Key` Class for describing the position and characteristics of a single key in the keyboard.
`class` | `Keyboard.Row` 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
`int` | `EDGE_BOTTOM`
`int` | `EDGE_LEFT`
`int` | `EDGE_RIGHT`
`int` | `EDGE_TOP`
`int` | `KEYCODE_ALT`
`int` | `KEYCODE_CANCEL`
`int` | `KEYCODE_DELETE`
`int` | `KEYCODE_DONE`
`int` | `KEYCODE_MODE_CHANGE`
`int` | `KEYCODE_SHIFT`

### Public constructors
`Keyboard(Context context, int xmlLayoutResId)` Creates a keyboard from the given xml key layout file.
`Keyboard(Context context, int xmlLayoutResId, int modeId, int width, int height)` Creates a keyboard from the given xml key layout file.
`Keyboard(Context context, int xmlLayoutResId, int modeId)` Creates a keyboard from the given xml key layout file.
`Keyboard(Context context, int layoutTemplateResId, CharSequence characters, int columns, int horizontalPadding)` 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
`int` | `getHeight()` Returns the total height of the keyboard
`List<Keyboard.Key>` | `getKeys()`
`int` | `getMinWidth()`
`List<Keyboard.Key>` | `getModifierKeys()`
`int[]` | `getNearestKeys(int x, int y)` Returns the indices of the keys that are closest to the given point.
`int` | `getShiftKeyIndex()`
`boolean` | `isShifted()`
`boolean` | `setShifted(boolean shiftState)`

### Protected methods
`Keyboard.Key` | `createKeyFromXml(Resources res, Keyboard.Row parent, int x, int y, XmlResourceParser parser)`
`Keyboard.Row` | `createRowFromXml(Resources res, XmlResourceParser parser)`
`int` | `getHorizontalGap()`
`int` | `getKeyHeight()`
`int` | `getKeyWidth()`
`int` | `getVerticalGap()`
`void` | `setHorizontalGap(int gap)`
`void` | `setKeyHeight(int height)`
`void` | `setKeyWidth(int width)`
`void` | `setVerticalGap(int gap)`

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## XML attributes

### android:horizontalGap

Default horizontal gap between keys.

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

Default height of a key, in pixels or percentage of display width.

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

Default width of a key, in pixels or percentage of display width.

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

Default vertical gap between rows of keys.

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

    public static final int EDGE_BOTTOM

Constant Value: 8 (0x00000008)

### EDGE_LEFT

    public static final int EDGE_LEFT

Constant Value: 1 (0x00000001)

### EDGE_RIGHT

    public static final int EDGE_RIGHT

Constant Value: 2 (0x00000002)

### EDGE_TOP

    public static final int EDGE_TOP

Constant Value: 4 (0x00000004)

### KEYCODE_ALT

    public static final int KEYCODE_ALT

Constant Value: -6 (0xfffffffa)

### KEYCODE_CANCEL

    public static final int KEYCODE_CANCEL

Constant Value: -3 (0xfffffffd)

### KEYCODE_DELETE

    public static final int KEYCODE_DELETE

Constant Value: -5 (0xfffffffb)

### KEYCODE_DONE

    public static final int KEYCODE_DONE

Constant Value: -4 (0xfffffffc)

### KEYCODE_MODE_CHANGE

    public static final int KEYCODE_MODE_CHANGE

Constant Value: -2 (0xfffffffe)

### KEYCODE_SHIFT

    public static final int KEYCODE_SHIFT

Constant Value: -1 (0xffffffff)

## Public constructors

### Keyboard

    public Keyboard (Context context,
                    int xmlLayoutResId)

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

    public Keyboard (Context context,
                    int xmlLayoutResId,
                    int modeId,
                    int width,
                    int height)

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

    public Keyboard (Context context,
                    int xmlLayoutResId,
                    int modeId)

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

    public Keyboard (Context context,
                    int layoutTemplateResId,
                    CharSequence characters,
                    int columns,
                    int horizontalPadding)

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.
`horizontalPadding` | `int`

## Public methods

### getHeight

    public int getHeight ()

Returns the total height of the keyboard

Returns
`int` | the total height of the keyboard

### getKeys

    public List<Keyboard.Key> getKeys ()

Returns
`List<Keyboard.Key>` |

### getMinWidth

    public int getMinWidth ()

Returns
`int` |

### getModifierKeys

    public List<Keyboard.Key> getModifierKeys ()

Returns
`List<Keyboard.Key>` |

### getNearestKeys

    public int[] getNearestKeys (int x,
                    int y)

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

Returns
`int[]` | 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

    public int getShiftKeyIndex ()

Returns
`int` |

### isShifted

    public boolean isShifted ()

Returns
`boolean` |

### setShifted

    public boolean setShifted (boolean shiftState)

Parameters
`shiftState` | `boolean`

Returns
`boolean` |

## Protected methods

### createKeyFromXml

    protected Keyboard.Key createKeyFromXml (Resources res,
                    Keyboard.Row parent,
                    int x,
                    int y,
                    XmlResourceParser parser)

Parameters
`res` | `Resources`
`parent` | `Keyboard.Row`
`x` | `int`
`y` | `int`
`parser` | `XmlResourceParser`

Returns
`Keyboard.Key` |

### createRowFromXml

    protected Keyboard.Row createRowFromXml (Resources res,
                    XmlResourceParser parser)

Parameters
`res` | `Resources`
`parser` | `XmlResourceParser`

Returns
`Keyboard.Row` |

### getHorizontalGap

    protected int getHorizontalGap ()

Returns
`int` |

### getKeyHeight

    protected int getKeyHeight ()

Returns
`int` |

### getKeyWidth

    protected int getKeyWidth ()

Returns
`int` |

### getVerticalGap

    protected int getVerticalGap ()

Returns
`int` |

### setHorizontalGap

    protected void setHorizontalGap (int gap)

Parameters
`gap` | `int`

### setKeyHeight

    protected void setKeyHeight (int height)

Parameters
`height` | `int`

### setKeyWidth

    protected void setKeyWidth (int width)

Parameters
`width` | `int`

### setVerticalGap

    protected void setVerticalGap (int gap)

Parameters
`gap` | `int`

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*