5
我有一个有趣的问题......我似乎无法找到解决方案。我使用ObjectAnimator旋转ImageView;但是onTouchListener只能注册MotionEvent.ACTION_DOWN。 (我从Log Cats中推导出来,还有MotionEvent.ACTION_MOVE和MotionEvent.ACTION_UP)。查看只有注册MotionEvent.ACTION_DOWN
我想也许这个问题与试图在同一时间试听和动画的问题有关。我在相对布局中包装了imageview和线性布局(设置为MATCH PARENT),并注册了线性布局以侦听触摸事件。线性布局具有相同的问题;只有MotionEvent.ACTION_UP正在处理中。有什么我需要去获得MotionEvent.ACTION_MOVE注册?
这里是我的代码:
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;
}
(很抱歉的格式混乱的代码...)