如何在ongestreperformed上禁用手势高亮动画



我正在做类似的手势检测从vogella教程在这里。

我的MainActivity是:

        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;
        }
    }

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

任何帮助都将非常感激。谢谢!

你可以通过setGestureColor(Color.TRANSPARENT)或settuncertaingesturecolor (Color.TRANSPARENT)来关闭这个

最新更新