@Override public View onCreateInputView() {
kv = (KeyboardView)getLayoutInflater().inflate(R.layout.keyboard, null);
keyboard = new Keyboard(this, R.xml.qwerty); kv.setKeyboard(keyboard);
UserDictionary.Words.addWord(this, "MadeUpWord", 10, "Mad", Locale.getDefault());
kv.setOnKeyboardActionListener(this);
return kv;
}
答案 0 :(得分:0)
您可以按照以下链接制作自定义键盘:
Create a Custom Keyboard on Android
创建一个名为res / layout / keyboard.xml的文件,并用以下内容替换其内容:
<?xml version="1.0" encoding="UTF-8"?>
<android.inputmethodservice.KeyboardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:keyPreviewLayout ="@layout/preview"
/>
keyPreviewLayout是短暂弹出窗口的布局,只要按下键盘上的键,就会显示该弹出窗口。它包含一个TextView。创建一个名为res / layout / preview.xml的文件,并将以下内容添加到其中:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:background="#ffff00"
android:textStyle="bold"
android:textSize="30sp"
>
</TextView>