I Have Webview In My Fragments And When Swiping Webview Than Viewpager Also Start Swiping
I was opening a solution of Stack Overflow in my webview so mobile version of that page opens in the webview. Now there is one code which requires horizontal scrolling to view it c
Solution 1:
So I override onTouch method in setOnTouchListener of the webView.
// to access the parent activity
ViewPager vpager = getActivity().findViewById(R.id.myViewPager);
webView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_DOWN ||
event.getAction()==MotionEvent.ACTION_POINTER_DOWN){
vpager.requestDisallowInterceptTouchEvent(true);
}else if(event.getAction()==MotionEvent.ACTION_UP ||
event.getAction()==MotionEvent.ACTION_POINTER_UP){
vpager.requestDisallowInterceptTouchEvent(false);
}
return false; // set it false for your webview to scroll correctly.
}
});
Post a Comment for "I Have Webview In My Fragments And When Swiping Webview Than Viewpager Also Start Swiping"