使用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:layout_height="match_parent"
android:gestureStrokeType="multiple"/>
</LinearLayout&