如何在onGesturePerformed上禁用手势高亮显示动画?

时间:2013-05-20 02:33:22

标签: android gesture gestures android-gesture

我正在从vogella教程here.

进行类似的手势检测

我的主要活动是:

        package com.example.gesturesaveopendocs;

    import java.util.ArrayList;

    import android.app.Activity;
    import android.gesture.Gesture;
    import android.gesture.GestureLibraries;
    import android.gesture.GestureLibrary;
    import android.gesture.GestureOverlayView;
    import android.gesture.GestureOverlayView.OnGesturePerformedListener;
    import android.gesture.Prediction;
    import android.os.Bundle;
    import android.view.Menu;
    import android.widget.Toast;

    public class MainActivity extends Activity implements
            OnGesturePerformedListener {

        GestureLibrary gesture_library;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            gesture_library = GestureLibraries
                    .fromRawResource(this, R.raw.gestures);
            if (!gesture_library.load()) {
                finish();
            }

            GestureOverlayView gestures = (GestureOverlayView) findViewById(R.id.gestures);
            gestures.addOnGesturePerformedListener(this);
        }

        public void onGesturePerformed(GestureOverlayView overlay, Gesture gesture) {
            ArrayList<Prediction> predictions = gesture_library.recognize(gesture);

            if (predictions.size() > 0 && predictions.get(0).score > 1.0) {
                String result = predictions.get(0).name;

                if ("open".equalsIgnoreCase(result)) {
                    Toast.makeText(this, "Opening the document", Toast.LENGTH_LONG)
                            .show();
                } else if ("save".equalsIgnoreCase(result)) {
                    Toast.makeText(this, "Saving the document", Toast.LENGTH_LONG)
                            .show();
                }
            }
        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }

    }

我想从屏幕上的手指手势中禁用高亮复制(黄色动画)。因为我只需要在我的应用程序中使用手势功能,而不会在每次刷卡时显示高亮动画。

任何帮助将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:2)

您可以通过GestureOverlayView上的setGestureColor(Color.TRANSPARENT)或setUncertainGestureColor(Color.TRANSPARENT)将其关闭。