我使用了https://play.google.com/store/apps/details?id=com.davemac327.gesture.tool&hl=en
手势工具,并注意到垂直从上到下的行不能检测,因为我在我的代码中使用生成的手势文件如下,但无法检测垂直的从上到下的手势检测
import java.util.Array@R_403_6818@;import androID.app.Activity;import androID.gesture.Gesture;import androID.gesture.GesturelibrarIEs;import androID.gesture.Gesturelibrary;import androID.gesture.GestureOverlayVIEw;import androID.gesture.Prediction;import androID.gesture.GestureOverlayVIEw.OnGesturePerformed@R_403_6818@ener;import androID.os.Bundle;import androID.Widget.Toast;public class GesturesActivity extends Activity implements OnGesturePerformed@R_403_6818@ener { private Gesturelibrary mlibrary; @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.main); mlibrary = GesturelibrarIEs.fromrawResource(this, R.raw.gestures); if (!mlibrary.load()) { finish(); } GestureOverlayVIEw gestures = (GestureOverlayVIEw) findVIEwByID(R.ID.gestures); gestures.addOnGesturePerformed@R_403_6818@ener(this); } public voID onGesturePerformed(GestureOverlayVIEw overlay, Gesture gesture) { Array@R_403_6818@<Prediction> predictions = mlibrary.recognize(gesture); String data=""; for (int i = 0; i < predictions.size(); i++) { data=data+ "=="+predictions.get(i).name; } // We want at least one prediction if (predictions.size() > 0) { Prediction prediction = predictions.get(0); // We want at least some confIDence in the result if (prediction.score > 1.0) { // Show the spell Toast.makeText(this,data+ " "+ prediction.name, Toast.LENGTH_SHORT).show(); } } }}
请建议如何执行垂直从上到下的垂直手势检测
解决方法:
我通过介绍解决了上述代码的问题
GestureOverlayVIEw gestures = (GestureOverlayVIEw) findVIEwByID(R.ID.gestures); gestures.setGesturestrokeAngleThreshold( 90.0f);
因为角度threashold的默认值是40.0f,因为它将跳过简单的垂直手势,所以将其更改为90.0f,所以最后将GesturestrokeAngleThreshold设置为接近90.0f的值可以正常工作
总结以上是内存溢出为你收集整理的android – 垂直从上到下的手势检测器全部内容,希望文章能够帮你解决android – 垂直从上到下的手势检测器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)