Custom gesture detector

醉酒当歌 提交于 2019-12-08 02:56:43

问题


I need to create some customs gesture to enable some particular settings on my app.

For example I need to create a L gesture like in the photo

There's a way to save gesture and then retrive when one of them are performed?


回答1:


There is an app installed on emulators called GestureBuilder, which allows you to save and record custom Gestures. If you don't want to run it in your emulator, you can also find it in the included SDK documents, just import it and run it on your device. See this article for more information.

Once you have the saved gesture file, then you need to copy the saved gesture file to your /res/raw folder, load it, and attach a gesture listener, as is done in this article:

gestureLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
     gestureLibrary.load();
 OnGesturePerformedListener gesturePerformedListener
 = new OnGesturePerformedListener(){

 @Override
 public void onGesturePerformed(GestureOverlayView view, Gesture gesture) {
  // TODO Auto-generated method stub
  ArrayList<Prediction> prediction = gestureLibrary.recognize(gesture);
  if(prediction.size() > 0){
   gestureResult.setText(prediction.get(0).name);
  }

 }};
}


来源:https://stackoverflow.com/questions/23134513/custom-gesture-detector

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!