【问题标题】:Android gesture recognition - vertical linesAndroid手势识别——竖线
【发布时间】:2014-03-31 06:02:22
【问题描述】:

我正在创建一个安卓应用程序。我在其中识别线(垂直和水平)。我已经使用了以下步骤。

1) Creating straight lines gesture file using "Gestures Builder" application. 
2) Added the "gestures" file in my application and used the "OnGesturePerformedListener" to recognize the line.

The problem is,
I can't recognize the vertical lines(Both Top to Bottom & Bottom to Top).

我可以识别垂直线以外的直线。有人可以知道如何获得垂直线检测吗?

代码sn-p:

public class GestureActivity extends Activity implements OnGesturePerformedListener {
    private GestureLibrary mLibrary;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GestureOverlayView gestureOverlayView = new GestureOverlayView(this);
    View inflate = getLayoutInflater().inflate(R.layout.activity_gesture,
            null);
    gestureOverlayView.addView(inflate);
    gestureOverlayView.addOnGesturePerformedListener(this);
    mLibrary = GestureLibraries.fromRawResource(this, R.raw.gestures);
    if (!mLibrary.load()) {
        finish();
    }
    setContentView(gestureOverlayView);
}

@Override
public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
    ArrayList<Prediction> predictions = mLibrary.recognize(gesture);
    if (predictions.size() > 0) {
        Prediction prediction = predictions.get(0);
        if (prediction.name.equals("Line") && prediction.score > 1.0) {
            Toast.makeText(this, "Line", Toast.LENGTH_LONG).show();
        }
    }

}

}

【问题讨论】:

  • 在此处发布您的代码以获得解决方案....
  • 请提供一些细节。
  • @Md Abdul Gafur:感谢您的回复。我已经在问题中发布了我的代码。
  • @G.V:感谢您的回复。我已经更新了我的问题

标签: android line gesture gesture-recognition


【解决方案1】:

我终于找到了解决方案。答案如下。

gestureOverlayView.setGestureStrokeAngleThreshold( 90.0f);

参考:https://stackoverflow.com/a/22807326/1485254

【讨论】:

    猜你喜欢
    • 2012-02-15
    • 2011-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多