java.lang.Object | |
↳ | android.inputmethodservice.Keyboard.Key |
Class for describing the position and characteristics of a single key in the keyboard.
XML Attributes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|||||||||
android:codes | The unicode value or comma-separated values that this key outputs. | ||||||||||
android:horizontalGap | Default horizontal gap between keys. | ||||||||||
android:iconPreview | The icon to show in the popup preview. | ||||||||||
android:isModifier | Whether this is a modifier key such as Alt or Shift. | ||||||||||
android:isRepeatable | Whether long-pressing on this key will make it repeat. | ||||||||||
android:isSticky | Whether this is a toggle key. | ||||||||||
android:keyEdgeFlags | Key edge flags. | ||||||||||
android:keyHeight | Default height of a key, in pixels or percentage of display width. | ||||||||||
android:keyIcon | The icon to display on the key instead of the label. | ||||||||||
android:keyLabel | The label to display on the key. | ||||||||||
android:keyOutputText | The string of characters to output when this key is pressed. | ||||||||||
android:keyWidth | Default width of a key, in pixels or percentage of display width. | ||||||||||
android:popupCharacters | The characters to display in the popup keyboard. | ||||||||||
android:popupKeyboard | The XML keyboard layout of any popup keyboard. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
codes | All the key codes (unicode or custom code) that this key could generate, zero'th being the most important. | |||||||||
|
edgeFlags | Flags that specify the anchoring to edges of the keyboard for detecting touch events that are just out of the boundary of the key. | |||||||||
|
gap | The horizontal gap before this key | |||||||||
|
height | Height of the key, not including the gap | |||||||||
|
icon | Icon to display instead of a label. | |||||||||
|
iconPreview | Preview version of the icon, for the preview popup | |||||||||
|
label | Label to display | |||||||||
|
modifier | Whether this is a modifier key, such as Shift or Alt | |||||||||
|
on | If this is a sticky key, is it on? | |||||||||
|
popupCharacters | Popup characters | |||||||||
|
popupResId | If this key pops up a mini keyboard, this is the resource id for the XML layout for that keyboard. | |||||||||
|
pressed | The current pressed state of this key | |||||||||
|
repeatable | Whether this key repeats itself when held down | |||||||||
|
sticky | Whether this key is sticky, i.e., a toggle key | |||||||||
|
text | Text to output when pressed. | |||||||||
|
width | Width of the key, not including the gap | |||||||||
|
x | X coordinate of the key in the keyboard layout | |||||||||
|
y | Y coordinate of the key in the keyboard layout |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Create an empty key with no attributes.
|
||||||||||
|
Create a key with the given top-left coordinate and extract its attributes from
the XML parser.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Returns the drawable state for the key, based on the current state and type of the key.
|
||||||||||
|
Detects if a point falls inside this key.
|
||||||||||
|
Informs the key that it has been pressed, in case it needs to change its appearance or
state.
|
||||||||||
|
Changes the pressed state of the key.
|
||||||||||
|
Returns the square of the distance between the center of the key and the given point.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
The unicode value or comma-separated values that this key outputs.
May be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
May be an integer value, such as "
100
".
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
codes
.
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), 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.
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
horizontalGap
.
The icon to show in the popup preview.
Must be a reference to another resource, in the form "
@[+][
package
:]
type
:
name
"
or to a theme attribute in the form "
?[
package
:][
type
:]
name
".
This corresponds to the global attribute
resource symbol
iconPreview
.
Whether this is a modifier key such as Alt or Shift.
Must be a boolean value, either "
true
" or "
false
".
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
isModifier
.
Whether long-pressing on this key will make it repeat.
Must be a boolean value, either "
true
" or "
false
".
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
isRepeatable
.
Whether this is a toggle key.
Must be a boolean value, either "
true
" or "
false
".
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
isSticky
.
Key edge flags.
Must be one or more (separated by '|') of the following constant values.
Constant | Value | Description |
---|---|---|
left
|
1 | Key is anchored to the left of the keyboard. |
right
|
2 | Key is anchored to the right of the keyboard. |
This corresponds to the global attribute
resource symbol
keyEdgeFlags
.
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), 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.
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
keyHeight
.
The icon to display on the key instead of the label.
Must be a reference to another resource, in the form "
@[+][
package
:]
type
:
name
"
or to a theme attribute in the form "
?[
package
:][
type
:]
name
".
This corresponds to the global attribute
resource symbol
keyIcon
.
The label to display on the key.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
keyLabel
.
The string of characters to output when this key is pressed.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
keyOutputText
.
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), 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.
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
keyWidth
.
The characters to display in the popup keyboard.
Must be a string value, using '\\;' to escape characters such as '\\n' or '\\uxxxx' for a unicode character.
This may also be a reference to a resource (in the form
"
@[
package
:]
type
:
name
") or
theme attribute (in the form
"
?[
package
:][
type
:]
name
")
containing a value of this type.
This corresponds to the global attribute
resource symbol
popupCharacters
.
The XML keyboard layout of any popup keyboard.
Must be a reference to another resource, in the form "
@[+][
package
:]
type
:
name
"
or to a theme attribute in the form "
?[
package
:][
type
:]
name
".
This corresponds to the global attribute
resource symbol
popupKeyboard
.
All the key codes (unicode or custom code) that this key could generate, zero'th being the most important.
Flags that specify the anchoring to edges of the keyboard for detecting touch events
that are just out of the boundary of the key. This is a bit mask of
EDGE_LEFT
,
EDGE_RIGHT
,
EDGE_TOP
and
EDGE_BOTTOM
.
Icon to display instead of a label. Icon takes precedence over a label
If this key pops up a mini keyboard, this is the resource id for the XML layout for that keyboard.
Text to output when pressed. This can be multiple characters, like ".com"
Create an empty key with no attributes.
Create a key with the given top-left coordinate and extract its attributes from the XML parser.
res | resources associated with the caller's context |
---|---|
parent |
the row that this key belongs to. The row must already be attached to
a
Keyboard
.
|
x | the x coordinate of the top-left |
y | the y coordinate of the top-left |
parser | the XML parser containing the attributes for this key |
Returns the drawable state for the key, based on the current state and type of the key.
Detects if a point falls inside this key.
x | the x-coordinate of the point |
---|---|
y | the y-coordinate of the point |
Informs the key that it has been pressed, in case it needs to change its appearance or state.
Changes the pressed state of the key. If it is a sticky key, it will also change the toggled state of the key if the finger was release inside.
inside | whether the finger was released inside the key |
---|
Returns the square of the distance between the center of the key and the given point.
x | the x-coordinate of the point |
---|---|
y | the y-coordinate of the point |