自 SDK 1.6 开始,Android手机已支持内置 Gesture Builder 程序,若是被Google签署(Signed)过出厂的手机应会内置此程序。
Gesture Builder 提供了手写识别的功能,让用户以类似于涂鸦的方式绘制一个手写符号,对应一个字符串名称,存储在 /mnt/sdcard/gestures
文件中。
为了练手,编写了Gesture Builder的应用程序,运行效果如下:
界面布局如下:
gesture_builder.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/gesture_builder_layout_top">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:textSize="18sp"
android:textColor="@android:color/white"
android:text="名称:"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="text"
android:background="@android:color/white"
android:id="@+id/gesture_builder_txt_name"/>
</LinearLayout>
<android.gesture.GestureOverlayView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gestureStrokeType="multiple"
android:gestureColor="#FFFF00"
android:layout_below="@+id/gesture_builder_layout_top"
android:layout_above="@+id/gesture_builder_layout_bottom"
android:layout_marginRight="30dp"
android:id="@+id/gesture_builder_gesture_overlay_view" >
</android.gesture.GestureOverlayView>
<SlidingDrawer
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:content="@+id/gesture_builder_content"
android:handle="@+id/gesture_builder_handler"
android:id="@+id/gesture_builder_sliding_drawer">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="SlidingDrawer"
android:src="@drawable/thumb_select"
android:id="@+id/gesture_builder_handler"/>
<ListView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:choiceMode="singleChoice"
android:background="@drawable/listview_bg"
android:divider="@drawable/listview_divider_style"
android:dividerHeight="2dp"
android:id="@+id/gesture_builder_content"></ListView>
</SlidingDrawer>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightSum="2"
android:layout_alignParentBottom&