Android 将ColorFilter设置为imageView

Android 将ColorFilter设置为imageView,android,ontouchlistener,Android,Ontouchlistener,我为imageView实现了onTouchListener,当触摸它时,它会在上面放置一个不透明度过滤器 ima.setOnTouchListener(new TextView.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (MotionEvent.ACTION_DOWN == event.ge

我为imageView实现了onTouchListener,当触摸它时,它会在上面放置一个不透明度过滤器

ima.setOnTouchListener(new TextView.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (MotionEvent.ACTION_DOWN == event.getAction()) {
                    ima.setColorFilter(0x80FFFFFF, PorterDuff.Mode.MULTIPLY);
                } else if (MotionEvent.ACTION_UP == event.getAction()) {
                    ima.clearColorFilter();
                    v.performClick();
                } else if (MotionEvent.ACTION_SCROLL == event.getAction()) {
                    ima.clearColorFilter();                      
                }
                else if (MotionEvent.ACTION_CANCEL == event.getAction()) {
                    ima.clearColorFilter();                       
                }
                return true;
            }
        });
当我在版面上滚动并误按图像时,它会突然将过滤器放入。
我需要把这个过滤器只有当我真的想按下这个图像。有什么有效的方法可以做到这一点吗?

定义“真的想按”。如果你成功了,你就有答案了。继续按imageview一段时间。例如0.2您可以使用
Handler.postDelayed(Runnable,long)
来实现这一点。在runnable中应用颜色过滤器,并在0.2尚未通过时在必要时取消。如果我使用处理程序,我需要中断它,以防在0.2通过之前退出。是这样吗?否则,imageview将始终保持绘制状态。我做到了,工作正常!