答案 0 :(得分:1)
最后,我找到了解决方案,早些时候我犯了错误,将键盘作为父布局,现在我重新设计我的XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.inputmethodservice.KeyboardView
android:id="@+id/keyboard1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:keyPreviewLayout="@layout/preview" />
<include
layout="@layout/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/keyboard1" />
</RelativeLayout>
我的onCreateInputView方法将如下所示
@Override
public View onCreateInputView() {
final RelativeLayout layout = (RelativeLayout) getLayoutInflater().inflate(R.layout.keyboard_layout, null);
kv = (KeyboardView) layout.findViewById(R.id.keyboard1);
keyboard = new Keyboard(this, R.xml.qwerty);
kv.setKeyboard(keyboard);
kv.setOnKeyboardActionListener(this);
return layout;
}