Adding and recognizing Android gestures

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.