TextView inside ViewPager intercepts touch events

前端 未结 2 550
我寻月下人不归
我寻月下人不归 2021-02-04 07:03

I have a ViewPager that contains two fragments. In any of the fragments I can touch a place, swipe to switch to another fragment. One of the fragments

2条回答
  •  梦毁少年i
    2021-02-04 07:56

    you can override onTouchEvent() of the TextView:

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_MOVE) {
            return false;
        }
    
        return super.onTouchEvent(event);
    }
    

提交回复
热议问题