2013-05-20 44 views
0

我是從vogella教程做類似的手勢檢測here.如何在onGesturePerformed上禁用姿態高亮動畫?

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

    } 

我想在屏幕上我的手指手勢禁用亮點複製(黃色動畫)。由於我只需要我的應用中的手勢功能,而不需要每次刷卡時都會顯示高亮顯示動畫。

任何幫助將不勝感激。謝謝!

回答

2

您可以通過GestureOverlayView上的setGestureColor(Color.TRANSPARENT)或setUncertainGestureColor(Color.TRANSPARENT)將其關閉。

+0

好吧,所以我嘗試了這一點,但是當我開始做出一個手勢時,突出顯示仍然在非常輕微的時刻出現。然後我發現這個'gestures.setGestureVisible(false);'所以這使得手勢動畫不可見。感謝輸入。乾杯! –