I have an interesting problem ... I can not find a solution. I use ObjectAnimator to rotate ImageView; but onTouchListener seems to register MotionEvent.ACTION_DOWN. (I deduced this from Log Cats, there is also MotionEvent.ACTION_MOVE and MotionEvent.ACTION_UP).
I thought that maybe the problem is related to trying to listen and animate the camera at the same time. I wrapped both the image and the linear layout (set in MATCH PARENT) in a relative layout and registered a linear layout for listening to touch events. Line layout has the same problem; only MotionEvent.ACTION_UP is processed. Is there something I need to register for MotionEvent.ACTION_MOVE?
Here is my code:
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;
}
( ...)