使用GestureLibrary添加手势:

主要功能:绘制手势完成后,弹出对话框,输入手势名称,点击保存,通过存储权限后,保存手势
我们使用Android提供的GestureOverlayView组件绘制手势,该组件的监听器可以响应手势事件的开始、结束、完成的事件
主界面布局
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请在下方绘制手势:"
android:textSize="36sp" />
<android.gesture.GestureOverlayView
android:id="@+id/govGesture"
android:layout_width="match_parent"

本文介绍了如何在Android应用中使用GestureLibrary组件和Gestures Builder软件来添加手势。首先,通过GestureOverlayView监听手势事件,并在用户完成手势后弹出对话框保存。接着,讲解了在AndroidManifest.xml中添加SD卡权限的步骤,确保能保存手势到指定文件。最后,详细说明了Gestures Builder的使用方法,包括创建手势和保存到本地的流程。
最低0.47元/天 解锁文章
920





