【发布时间】:2017-10-02 18:39:41
【问题描述】:
在我的 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:keyBackground="@drawable/square_rounded"
android:background="#ffffff">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/mainLinearLayout">
<RelativeLayout
android:id="@+id/keyboardLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:text="Cancel"
android:layout_alignParentLeft="true">
</Button>
<Button
android:layout_width="100dp"
android:layout_height="50dp"
android:text="Done"
android:layout_alignParentRight="true">
</Button>
<LinearLayout
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</android.inputmethodservice.KeyboardView>
然后尝试像这样加载它:
kv = (KeyboardView)getLayoutInflater()
.inflate(R.layout.draw_signature, null);
kv.setOnKeyboardActionListener(this);
kv.setPreviewEnabled(false);
return kv;
任何帮助或教程链接将不胜感激。
【问题讨论】:
-
这个运气好吗?我有同样的问题。
标签: android android-softkeyboard custom-keyboard