Comments (11)
Same problem here. Would be nice if someone has an idea how to resolve this issue.
from androidpdfviewer.
public class PDFViewPager extends ViewPager {
public PDFViewPager(Context context) {
super(context);
}
public PDFViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
if (v instanceof ViewGroup) {
final ViewGroup group = (ViewGroup) v;
final int scrollX = v.getScrollX();
final int scrollY = v.getScrollY();
final int count = group.getChildCount();
for (int i = count - 1; i >= 0; i--) {
final View child = group.getChildAt(i);
if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() &&
y + scrollY >= child.getTop() && y + scrollY < child.getBottom()) {
if ((child instanceof PDFView && isNotHorizontalBounds((PDFView)child, dx)) || canScroll(child, true, dx, x + scrollX - child.getLeft(),
y + scrollY - child.getTop()))
return true;
}
}
}
return checkV && false;
}
private boolean isNotHorizontalBounds(PDFView view, int dx) {
final float zoom = view.getZoom();
final float pageWidth = view.getWidth()*zoom;
final float offset = view.getCurrentXOffset();
if (offset + pageWidth <= getWidthScreen() + 1 && dx < 0) return false;
if (offset >= -1 && dx > 0) return false;
return true;
}
private int getWidthScreen(){
WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
return size.x;
}
}
from androidpdfviewer.
That's because canScrollHorizontally(int direction)
is not implemented, which is already requested in issue #19
from androidpdfviewer.
Hi @MonaHammad!
The ViewPager is part of the android support library: https://developer.android.com/reference/android/support/v4/view/ViewPager.html
It is not related to this PDF library. This issue here is relevant if you show multiple PDFs inside a view pager. Hope this helps.
best
from androidpdfviewer.
Had the same problem, but fixed it with overriding VP canScroll method
from androidpdfviewer.
@paperrose can you write an example how you've implemented the canScroll functionality?
from androidpdfviewer.
@paperrose works lke a charm. thanks ;-)
from androidpdfviewer.
Thank you , it works
from androidpdfviewer.
Just find a small bug in my code above. In landscape orientation right-to-left swipe doesn't change page
Solved by replacing
final float pageWidth = view.getWidth()*zoom;
to
final float pageWidth = view.getOptimalPageWidth()*zoom;
from androidpdfviewer.
How to use this approach, I can't find ViewPager class?
from androidpdfviewer.
Hi @peshkira
Ok, thanks.
But how to use it here to improve the paging while zooming in this library?
I couldn't figure out how to use PDFViewPager?
from androidpdfviewer.
Related Issues (20)
- What is the freetype and littlecms version you are using? HOT 1
- Is not working for jbr 17 HOT 1
- Password protected PDFs not working HOT 1
- VivoY72.gitignore
- 无法显示pdf中的签名信息 HOT 1
- Blank space before PDF HOT 1
- autoScrolly
- AndroidPdfViewer with Supporting Android API >=21 HOT 1
- Duplicate conflict 'lib/arm64-v8a/libc++_shared.so' with OpenCV lib
- .
- PDF page half portion shown blur on many pdfs.
- Unable to go till end of page if autoSpacing set to true
- Cant' compile after adding library Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
- Future of the project HOT 15
- Primer proyecto
- 使用PdfViewer加载本地Pdf文件预览时,pdf文件中的内容会出现拉伸 HOT 2
- ❗Repo not found or no token provided HOT 2
- facing issue in going to specific page in search in pdf in kotline andriod studio
- UnsatisfiedLinkError with PDFium on Android 15 Emulator with 16 KB Page Size
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from androidpdfviewer.