Android : Gesture Builder:自定义手势文件

本文介绍了如何使用Android内置的Gesture Builder创建自定义手势。通过手势识别功能,用户可以绘制手势并将其关联到特定字符串。文中详细讲解了应用的界面布局、样式、适配器及Activity的实现,并提到了在AndroidManifest.xml中设置外部存储访问权限的重要性。
摘要由CSDN通过智能技术生成

自 SDK 1.6 开始,Android手机已支持内置 Gesture Builder 程序,若是被Google签署(Signed)过出厂的手机应会内置此程序。

Gesture Builder 提供了手写识别的功能,让用户以类似于涂鸦的方式绘制一个手写符号,对应一个字符串名称,存储在 /mnt/sdcard/gestures 文件中。

为了练手,编写了Gesture Builder的应用程序,运行效果如下:

gesture builder

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&
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值