Open JeanChristophePal opened 8 years ago
The problem is mainly due to the ScrollView behavior. To swipe horizontally a PDFView, which is in a Vertical Scrollview, motion has to be rigorously horizontal, if its a little UP or DOWN the swipe is stopped...
The hack found on internet is to test the motion distance (more vertically than horizontally?):
public class EnableLateralMotionScrollView extends ScrollView {
private GestureDetector mGestureDetector;
public EnableLateralMotionScrollView(Context context, AttributeSet attrs ) {
super(context, attrs);
mGestureDetector = new GestureDetector(context, new YScrollDetector());
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return super.onInterceptTouchEvent(ev) && mGestureDetector.onTouchEvent(ev);
}
// Return false if we're scrolling in the x direction
class YScrollDetector extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
return Math.abs(distanceY) > Math.abs(distanceX);
}
}
}
This is not perfect but it worked.
Do you have a better solution?
I find this another workable solution using ScrollView subclass (my case is in minSDKVersion API 16)
public class NoInterceptScrollView extends ScrollView {
public NoInterceptScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return false;
}
}
refer: https://stackoverflow.com/questions/17671123/scrollview-inside-a-scrollview-in-android-issue
Hello,
I need to put the PDFView in a ScrollView, how should I do it?
So far, either the PDFView is not showing or the scroll is not working.
Thank you