2012-05-12 15 views
5

Ho un problema interessante ... che non riesco a trovare la soluzione per. Sto usando un ObjectAnimator per ruotare un ImageView; ma onTouchListener sembra solo registrare MotionEvent.ACTION_DOWN. (Ho dedotto questo dai Log Cats, c'è anche MotionEvent.ACTION_MOVE e MotionEvent.ACTION_UP).Visualizza solo registrando MotionEvent.ACTION_DOWN

Ho pensato che forse il problema aveva a che fare con il tentativo di ascoltare e animare ad una visione allo stesso tempo. Ho avvolto sia la vista di immagini sia un layout lineare (impostato su MATCH PARENT) in un layout relativo e ho registrato il layout lineare per ascoltare gli eventi touch. Il layout lineare ha lo stesso problema; viene gestito solo MotionEvent.ACTION_UP. C'è qualcosa che devo fare per ottenere MotionEvent.ACTION_MOVE per essere registrato?

Ecco il mio codice:

  touch_pad = (LinearLayout) findViewById(R.id.layout_touch_capture); 
    touch_pad.setOnTouchListener(this); 
    touch_pad.requestFocus(); 

      public boolean onTouch(View v, MotionEvent event) { 
    switch(v.getId()) { 
    case (R.id.layout_touch_capture): 

    long end = 0; 
    long start = 0; 
    float y = event.getY(); 
    float y_sum = y; 
    float x = event.getX(); 

    switch(event.getAction()) { 
    case (MotionEvent.ACTION_UP): 
     end = animator.getCurrentPlayTime(); 
    Log.d("WheelActivity", "end location = " + end); 
    break; 
    case (MotionEvent.ACTION_MOVE): 

    Log.d("WheelActivity", "event.getY() = " + y); 
    y_sum += y; 
    animator.setCurrentPlayTime((long) (start + y_sum)); 
    Log.d("WheelActivity", "animator play time = "        animator.getCurrentPlayTime()); 
    Log.d("WheelActivity", "animator fraction = " + 
      animator.getAnimatedFraction()); 

    break; 
    case (MotionEvent.ACTION_DOWN): 
     start = animator.getCurrentPlayTime(); 
    Log.d("WheelActivity", "start location = " + start); 
    break; 
    } 
    } 
    return false; 
} 

(Ci scusiamo per il codice mal formattato ...)

risposta

12
return false; 

cambiato in return true;

Problemi correlati