Tengo un problema interesante ... que parece que no puedo encontrar la solución. Estoy usando un ObjectAnimator para rotar un ImageView; pero el onTouchListener solo parece registrar MotionEvent.ACTION_DOWN. (Lo deduje de los Log Cats, también hay MotionEvent.ACTION_MOVE y MotionEvent.ACTION_UP).Ver solo registrando MotionEvent.ACTION_DOWN
Pensé que tal vez el problema tenía que ver con tratar de escuchar y animar a un veiw al mismo tiempo. Envolví tanto la vista de la imagen como el diseño lineal (establecido en MATCH PARENT) en un diseño relativo, y registré el diseño lineal para escuchar los eventos táctiles. El diseño lineal tiene el mismo problema; solo se está manejando MotionEvent.ACTION_UP. ¿Hay algo que deba hacer para que MotionEvent.ACTION_MOVE esté registrado?
Aquí está mi código:
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;
}
(Perdón por el código de mal formateado ...)