I had the same problem. My solution was: Make a subclass of ViewPager and add a property called childId Implement the interface ViewPager. OnPageChangeListener and in onPageSelected method, set 'childId' property with the id of the HorizontalScrollView only in the page where the HorizontalScrollView is visible and set 0 in other cases Override onInterceptTouchEvent in the subclass of ViewPager and if the 'childId' property is more than 0 get that child and if the event is in HorizontalScrollView area return false Code public class CustomViewPager extends ViewPager { private int childId; public CustomViewPager(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent event) { if (childId > 0) { View scroll = findViewById(childId); if (scroll!
= null) { Rect rect = new Rect(); scroll. Get Contains((int) event.getX(), (int) event.getY())) { return false; } } } return super. OnInterceptTouchEvent(event); } public void setChildId(int id) { this.
ChildId = id; } } In onCreate method viewPager. SetChildId(R.id. HorizontalScrollViewId); adapter = new ViewPagerAdapter(this); viewPager.
SetAdapter(adapter); viewPager. SetOnPageChangeListener(new ViewPager. OnPageChangeListener() { @Override public void onPageSelected(int position) { // I have the HorizontalScrollView in first page if (position == 0) { viewPager.
SetChildId(R.id. HorizontalScrollViewId); } else { viewPager. SetChildId(0); } } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int state) { } }) Hope this help.
I had the same problem. My solution was: Make a subclass of ViewPager and add a property called childId. Implement the interface ViewPager.
OnPageChangeListener and in onPageSelected method, set 'childId' property with the id of the HorizontalScrollView only in the page where the HorizontalScrollView is visible and set 0 in other cases. Override onInterceptTouchEvent in the subclass of ViewPager and if the 'childId' property is more than 0 get that child and if the event is in HorizontalScrollView area return false. Code public class CustomViewPager extends ViewPager { private int childId; public CustomViewPager(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent event) { if (childId > 0) { View scroll = findViewById(childId); if (scroll!
= null) { Rect rect = new Rect(); scroll. Get Contains((int) event.getX(), (int) event.getY())) { return false; } } } return super. OnInterceptTouchEvent(event); } public void setChildId(int id) { this.
ChildId = id; } } In onCreate method viewPager. SetChildId(R.id. HorizontalScrollViewId); adapter = new ViewPagerAdapter(this); viewPager.
SetAdapter(adapter); viewPager. SetOnPageChangeListener(new ViewPager. OnPageChangeListener() { @Override public void onPageSelected(int position) { // I have the HorizontalScrollView in first page if (position == 0) { viewPager.
SetChildId(R.id. HorizontalScrollViewId); } else { viewPager. SetChildId(0); } } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int state) { } }); Hope this help.
Thanks for the reply. I modified your solution a bit and managed to make nested ViewPagers work: public class CustomViewPager extends ViewPager { private int childId; public CustomViewPager(Context context, AttributeSet attrs) { super(context, attrs); } @Override public boolean onInterceptTouchEvent(MotionEvent event) { if (childId > 0) { ViewPager pager = (ViewPager)findViewById(childId); if (pager! = null) { pager.
RequestDisallowInterceptTouchEvent(true); } } return super. OnInterceptTouchEvent(event); } public void setChildId(int id) { this. ChildId = id; } }.
I was having trouble with a small gallery view on the foot of my first page in a viewpager group. On swiping the gallery view focus would jump between moving the gallery items or the viewpager. Overriding ViewPager as listed above and setting requestDisallowInterceptTouchEvent solved my problem.
The pages no longer change when swiping the galleryview. Think its an important solution for those using galleryviews with viewpager.
One situation that could happen is that I could have more than one HorizontalScrollView inside my ViewPager (which I do), and then I would need to provide tons of Ids to the ViewPager so it can always check for child touch conflicts. I analyzed the source from the ViewPager, and found that they use this method called "canScroll" to determine if a child view can be scrolled. Luckily, it wasn't made static nor final, so I could just override it.
Inside that method that the "boolean ViewCompat.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.