Layout XML:
<Android. gesture. gestureoverlayview
Android: Id = "@ + ID/gesture1"
Android: layout_width = "fill_parent"
Android: layout_height = "fill_parent"
Android: gesturestroketype = "multiple">
</Android. gesture. gestureoverlayview>
* ** Android. gesture. gestureoverlayview is the gesture input view. Note that the label here is not gestureoverlayview.
The following describes how to add a gesture:
1. Get the gesture Library first.
Gesturelibrary = gesturelibraries. fromfile ("/sdcard/mygestures ");
2. Determine whether gesture loading is successful
If (gesturelibrary. Load ()){
Toast. maketext (registerdialog. This, "the file is loaded successfully, enter the gesture you want to modify", Toast. length_long). Show ();
} Else {
Toast. maketext (registerdialog. This, "file loading failed", Toast. length_short). Show ();
}
3. Listen to addongesturesponmedlistener after the gesture is drawn.
4. Add and save gestures
Gesturelibrary. addgesture ("Default gesture", gesture );
Gesturelibrary. Save ();
Let's talk about gesture recognition:
1. first obtain the gesture Library
Gesturelibrary = gesturelibraries. fromfile ("/sdcard/mygestures ");
2. Determine whether the gesture library is loaded successfully
If (library. Load ())
3. Listen to addongesturesponmedlistener after the gesture is drawn.
4. Call the gesturelibrary MethodRecognize(GestureGesture) returns the arraylist <prediction> object.
5. loop traversal arraylist object, which uses the score of prediction to match the similarity of gestures, all candidate gestures matching the matching gestures are saved in the arraylist.