requestDisallowInterceptTouchEvent does not work unless selecting view first

前端 未结 2 1657

According to android docs you can get your parent ViewGroup and call requestDisallowInterceptTouchEvent(true) on it to stop other things from interferi

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 12:40

    You can try this one:

    m_parentScrollView.setOnTouchListener(new View.OnTouchListener() 
    {
           public boolean onTouch(View p_v, MotionEvent p_event) 
            {
                   m_childScrollView.getParent().requestDisallowInterceptTouchEvent(false);
               //  We will have to follow above for all scrollable contents
               return false;
            }
    });
    
                                            **OR**
    
    m_childScrollView.setOnTouchListener(new View.OnTouchListener() 
    {
          public boolean onTouch(View p_v, MotionEvent p_event)
           {
              // this will disallow the touch request for parent scroll on touch of child view
               p_v.getParent().requestDisallowInterceptTouchEvent(true);
               return false;
           }
    });
    

提交回复
热议问题