onInterceptTouchEvent, onTouchEvent only see ACTION_DOWN

后端 未结 4 1139
春和景丽
春和景丽 2021-01-18 11:56

I have a top level ViewGroup, which I call SliderView, in which I want to detect swiping. This is mostly working, but one weird failure persists.

The essence of Sli

4条回答
  •  离开以前
    2021-01-18 12:24

    All you need is to call

    requestDisallowInterceptTouchEvent(true);
    

    on the parent view, like this -

            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                view.getParent().requestDisallowInterceptTouchEvent(true);
                switch(motionEvent.getActio){
                }
    
                return false; 
    
             }
    

提交回复
热议问题