Handwriting Soft Keyboard Android

I am working on an android android app that should display a drawn canvas instead of a normal soft keyboard based keyboard. Just like Google Handwriting Keyboard I don't want to implement candidate submission or handwriting recognition. My keyboard will just take the text in the canvas and send it as an image.

However, after a lot of research, I still cannot show the canvas view instead of the keyboard view. I followed him:

https://code.tutsplus.com/tutorials/create-a-custom-keyboard-on-android--cms-22615

But this adds a keyboard from the keyboard. I don't want to have a numeric or character keyboard. I just want the keyboard to display a blank canvas that I can draw on and after that it should send that image.

I also tried setting a layout like this:

<?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>

      

and then tried loading it like:

kv = (KeyboardView)getLayoutInflater().inflate(R.layout.draw_signature, null);
//            keyboard = new Keyboard(this, R.xml.drawing_keyboard);
//            kv.setKeyboard(keyboard);
kv.setOnKeyboardActionListener(this);
kv.setPreviewEnabled(false);
return kv;

      

Any help or tutorial link would be appreciated.

Thank you, Anand

+3


source to share





All Articles