Skip to content Skip to sidebar Skip to footer

Allow Scrolling Edittext And Swiping Viewpager

I have an EditText (vertically scrollable) inside one of the fragments in a ViewPager (horizontally swipable). By default, touch events inside the EditText can swipe the ViewPager

Solution 1:

You can handle this according to the solution given here.

pager.setOnTouchListener(newView.OnTouchListener() 
{
       publicbooleanonTouch(View p_v, MotionEvent p_event) 
        {
               editText.getParent().requestDisallowInterceptTouchEvent(false);
           //  We will have to follow above for all scrollable contentsreturnfalse;
        }
});

For the EditText, you will have to add this snippet.

editText.setOnTouchListener(newView.OnTouchListener() 
{
      publicbooleanonTouch(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);
           returnfalse;
       }
});

Hope it helps...

Post a Comment for "Allow Scrolling Edittext And Swiping Viewpager"