如何创建智能键盘?

问题描述 投票:-4回答:1

我正在开发一个需要自定义键盘的应用程序。自定义意味着不自定义键,但我需要在键盘内部显示不同的布局。我附上了我正在寻找的图像,请指导我如何实现这一目标。

任何线索或建议将被赞赏enter image description here

android custom-keyboard
1个回答
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;
    }
© www.soinside.com 2019 - 2024. All rights reserved.