I am developing a PDF viewer app using the AndroidPdfViewer library for a glass device. Currently, I cannot perform a touch scroll and it has to be done programmatically.
The scrolling function works but just on one page and jump very ugly to the other pages, but it is not smooth like when I run the app on an emulator(all pages like one page and not ugly jump).
I want to simulate a touch scroll programmatically to achieve the same behavior as if it were on a mobile phone.
This work, but only scroll to the first page
binding.pdfView.post { binding.pdfView.scrollY += View.FOCUS_DOWN}
then this allows me to do it in all documents put with a jump between pages that does not look like a touch scroll on any device.
val pdfView: PDFView = binding.pdfView
if (pdfView.scrollY < pdfView.bottom) {
pdfView.post { pdfView.scrollTo(0, pdfView.scrollY + View.FOCUS_DOWN) }
} else if (pdfView.currentPage < pdfView.pageCount - 1) {
binding.pdfView.jumpTo(pdfView.currentPage.plus(1))
pdfView.scrollY = 0
}
And the end I have to change the approach and use the variable positionOffsett
val pdfView: PDFView = binding.pdfView
val direction = pdfView.positionOffset + scrollDirection //0.01F
pdfView.setPositionOffset(direction, true)
scrollDirection
can be positive or negative depending if you want to go UP or DOWN on the scroll