0

我在这里从 vogella 教程中进行了类似的手势检测

我的主要活动是:

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

    }

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

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

4

1 回答 1

2

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

于 2013-05-20T03:01:13.467 回答