Android Viewpager With Scrollviews With Viewpagers Inside The Scrollviews
So I have my activity which has a main ViewPager and inside of the ViewPager each page has the whole content as a ScrollView and inside of that ScrollView there is another ViewPage
Solution 1:
In case anyone wants to know my solution:
publicclassCustomScrollViewextendsScrollView {
private GestureDetector mGestureDetector;
View.OnTouchListener mGestureListener;
publicCustomScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
mGestureDetector = newGestureDetector(context, newYScrollDetector());
setFadingEdgeLength(0);
}
@OverridepublicbooleanonInterceptTouchEvent(MotionEvent ev) {
returnsuper.onInterceptTouchEvent(ev)
&& mGestureDetector.onTouchEvent(ev);
}
// Return false if we're scrolling in the x directionclassYScrollDetectorextendsSimpleOnGestureListener {
@OverridepublicbooleanonScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
if (Math.abs(distanceY) > Math.abs(distanceX)) {
returntrue;
}
returnfalse;
}
}
}
and the outer most ViewPager is:
publicclassNestingViewPagerextendsViewPager {
publicNestingViewPager(final Context context, final AttributeSet attrs) {
super(context, attrs);
}
publicNestingViewPager(final Context context) {
super(context);
}
@OverrideprotectedbooleancanScroll(View v, boolean checkV, int dx, int x, int y) {
if (v != this && v instanceof ViewPager) {
returntrue;
}
returnsuper.canScroll(v, checkV, dx, x, y);
}
}
Post a Comment for "Android Viewpager With Scrollviews With Viewpagers Inside The Scrollviews"