I have a ViewPager inside Activity. The ViewPager is inside the ScrollView. In the fragment I have RecyclerView. When I scroll the recycler item I need to disable the activity scroll. How do I achieve that. I search on but nothing found. Please help me in it. I stuck for sometime in this issue.
Asked
Active
Viewed 493 times
-1
Phantômaxx
- 37,901
- 21
- 84
- 115
Rishikesh Rahi
- 13
- 2
- 9
3 Answers
1
Please try requestDisallowInterceptTouchEvent on view like bellow
yourviewpager.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
recyclerview.requestDisallowInterceptTouchEvent(true);
//or you can apply on ScrollView also
//scrollview.requestDisallowInterceptTouchEvent(true);
return false;
}
});
Dhaval Solanki
- 4,589
- 1
- 23
- 39
-
vpChatType.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { my_scrolview.requestDisallowInterceptTouchEvent(true); //or you can apply on ScrollView also //scrollview.requestDisallowInterceptTouchEvent(true); return false; } }); – Rishikesh Rahi May 22 '19 at 07:55
-
Okay, let me try with your same scenario. – Dhaval Solanki May 22 '19 at 07:56
0
You cannot disable the scrolling of a ScrollView. You would need to extend to ScrollView and override the onTouchEvent method to return false when some condition is matched.
More info here: Disable ScrollView Programmatically?
More info about ViewPager: Is it possible to disable scrolling on a ViewPager
Tlaloc-ES
- 4,825
- 7
- 38
- 84
-
Actually i saw the link as you provided but the thing is inside the scrollview i have viewpager. And recyclerview is inside the fragment. then how do i disable the activity scrollview? – Rishikesh Rahi May 22 '19 at 07:49
0
Add this tag into your RecyclerView in XML layout
android:overScrollMode="always"
Rishabh Sagar
- 3,877
- 3
- 15
- 24