Introduction
This article explains how to create and detect your own gestures in Android.
Android shows the gestures in yellow for recognized gestures and a lighter yellow for gestures that are not registered. You can turn this off, via setGestureColor(Color.TRANSPARENT) or setUncertainGestureColor(Color.TRANSPARENT) on the GestureOverlayView.
Step 1
First, let us create some gestures.
Start your emulator. Open the "Gestures Builder" app in your emulator. You will see something like:

At present in this emulator, no gestures have been added.
Add some gestures by clicking on "Add gesture".

Enter a name for your gesture and draw the gesture in the remaining area and click on done. For example:

I have added 3 gestures with names "happy", "sad", "surprised" as in the following:

You can also rename the gesture added by holding the click/touch on the gesture name in the list shown above.
After creating the gestures, the most obvious step is to pull the gesture file and add it to your project.
Step 2
For pulling the gesture file from the emulator.
Open Android Debug Monitor (DDMS included) then select "File Explorer" -> "mnt" -> "sdcard" -> "gestures". Now click on "Pull a file from device" in the top right corner. Save this file anywhere on your computer. I have saved this with the name "expressions".
Step 3
Right-click on res then select "New" -> "Android Resource Directory". Name the directory "raw" and choose the type as "raw".
Copy the file saved in step 2 (expressions in this case), to the clipboard and paste it in the "raw" folder that you created.
Now you can use this file.
Step 4
Open "activity_main" and add the following code to it:
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="#ffc366" >
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textSize="20dp"
- android:gravity="center_horizontal"
- android:text="Draw the expression"
- android:layout_margin="10dip"/>
- <android.gesture.GestureOverlayView
- android:id="@+id/gesture_area"
- android:layout_width="fill_parent"
- android:layout_height="0dip"
- android:layout_weight="1.0"
- android:background="#454545"/>
- </LinearLayout>






Comments
Join the conversation! Your thoughts help the community grow.