Returning false in OnTouch on ImageView but still event is getting consumed

前端 未结 3 715
南旧
南旧 2021-01-20 04:08

I am using ImageView.onTouch(). I am returning false for ACTION_MOVE but still the onTouch() event is consumed.

imageV         


        
3条回答
  •  醉酒成梦
    2021-01-20 04:35

    This works too, but I'm still not 100% sure what you are asking to do. This sets the imageView clickable to false and should therefore allow the touch not to be consumed by it. Also, I added clickable to the LinearLayout.

     imageView.setOnTouchListener(new View.OnTouchListener() {
    
            @Override
            public boolean onTouch(View v, MotionEvent ev) {
                System.out.println("jan25 iv onTouch");
    
                if (ev.getActionMasked()==MotionEvent.ACTION_DOWN) {
                    System.out.println("jan25 iv ACTION_DOWN");
                    return true;
                }
    
                if (ev.getActionMasked()==MotionEvent.ACTION_MOVE){
                    System.out.println("jan25 iv ACTION_MOVE");
                    imageView.setClickable(false);
                    return false;
    
                }
                if (ev.getActionMasked()==MotionEvent.ACTION_UP){
                    System.out.println("jan25 iv ACTION_UP");
                    return true;
                }
    
                System.out.println("jan25 iv false");
                return false;
    
            }
        });
    
    
    
        
    
    

提交回复
热议问题