public final class KeyboardController extends Object
You can use the methods provided in this class to switch between input methods, hide input method keyboards, set the keyboard layout, and obtain and set the keyboard display mode.
SystemCapability.Miscservices#INPUTMETHOD| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
DISPLAY_MODE_FULL |
Indicates that the current keyboard is displayed in full-screen mode.
|
static int |
DISPLAY_MODE_PART |
Indicates that the current keyboard is displayed in partial screen (normal mode).
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
int |
getDisplayMode() |
Obtains the real-time display mode of the keyboard.
|
int |
getScreenOrientation() |
Obtains the real-time screen direction.
|
void |
hideKeyboard() |
Hides the keyboard.
|
void |
setDisplayMode(int mode) |
Sets or changes the keyboard display mode.
|
boolean |
setKeyboardContainer(ComponentContainer container) |
Sets the keyboard component container.
|
boolean |
toNextInputMethod() |
Switches to the next input method application.
|
public static final int DISPLAY_MODE_FULL
The full-screen mode means that the keyboard window occupies the entire screen. In this mode, the edit box
on the client is blocked. Therefore, the input method application must be able to draw and display a keyboard
and a custom edit box. The custom edit box can use the KeyboardDelegate callback interface to
synchronize the cursor position and the text being entered in the edit box on the client.
public static final int DISPLAY_MODE_PART
In normal mode, the keyboard window occupies a part of the screen, and the remaining part of the screen is occupied by the window where the edit box of the client is located. The normal mode is commonly used by most input method applications.
public void setDisplayMode(int mode)
Your application can use this method to notify the framework of the expected keyboard display mode. The setting takes effect next time the keyboard window is displayed.
mode - Indicates the keyboard display mode to set. DISPLAY_MODE_PART indicates partial screen
(normal mode), and DISPLAY_MODE_FULL indicates the full-screen mode.public int getDisplayMode()
DISPLAY_MODE_PART if the keyboard is displayed in partial screen (normal mode);
returns DISPLAY_MODE_FULL if the keyboard is displayed in full-screen mode.public void hideKeyboard()
public boolean toNextInputMethod()
true if the operation is successful; returns false otherwise.public int getScreenOrientation()
Configuration.DIRECTION_VERTICAL if the screen is displayed
vertically; returns Configuration.DIRECTION_HORIZONTAL if the screen is
displayed horizontally.public boolean setKeyboardContainer(ComponentContainer container)
This method can be used to set or change the keyboard component container. You can set custom UI components in the container.
container - Indicates the container to set.true if the operation is successful; returns false otherwise.