gpt4 book ai didi

android - 查看只注册 MotionEvent.ACTION_DOWN

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:58:48 25 4
gpt4 key购买 nike

我遇到了一个有趣的问题...我似乎无法找到解决方案。我正在使用 ObjectAnimator 来旋转 ImageView;但 onTouchListener 似乎只注册了 MotionEvent.ACTION_DOWN。 (我从 Log Cats 中推导出来,还有 MotionEvent.ACTION_MOVE 和 MotionEvent.ACTION_UP)。

我认为问题可能与尝试同时聆听和动画化一个 View 有关。我将 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;
}

(抱歉,格式不正确的代码...)

最佳答案

return false;  

改为return true;

关于android - 查看只注册 MotionEvent.ACTION_DOWN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10564200/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com