B4J Question Scrollbar in ScrollView not working

knutf

Member
Licensed User
Longtime User
Hello

In the PDFBoxWrapperExample I posted in B4J Share our Creations I have problems with the Horisontal Scrollvbar in the ScrollView.

When it happens, the right arrow button in the horizontal scrollbar is missing, and it is not possible to scroll the ScrollView horizontaly. Missing arrow button is marked with blue circle and arrow on attached image

Can anyone give me a hint how it can be solved?

To reproduce:
  1. Open a PDF-document
  2. Zoom the document out until the horizontal scrollbar disappears
  3. Zoom the document in until thehorizontal scrollbar appears again. Now it is likely the problem turns out.
PDFBoxWrapperExampleMissingScrollbarButton.png
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Nice app!

There is a problem in your code. Add:
B4X:
myScrollPane.HPosition = (r.x + PositionInDocument.x * r.width - PositionInScrollPane.x) / (pneMyPages.PrefWidth - vpWidth)
Log(myScrollPane.HPosition) '<-----------

You will see that it is NaN (not a number) in some cases. It happens because you divide by 0.

Note that you can increase the scroll bar size by setting the ScrollPane text size (Extra CSS in the designer):
B4X:
-fx-font-size:  20;

You can also add drag and drop feature. Example: https://www.b4x.com/android/forum/threads/tool-b4xlib-xml-generation.101450/#content
 
Upvote 0

knutf

Member
Licensed User
Longtime User
Nice app!
Thank you! I have made it for fun, maybe someone else can use the Class Module in their project!

There is a problem in your code. Add:
B4X:
myScrollPane.HPosition = (r.x + PositionInDocument.x * r.width - PositionInScrollPane.x) / (pneMyPages.PrefWidth - vpWidth)
Log(myScrollPane.HPosition) '<-----------
You will see that it is NaN (not a number) in some cases. It happens because you divide by 0.

Of course, your right dividing by zero happens every so often in this code, thank you. My code is now:
B4X:
If pneMyPages.PrefWidth > vpWidth Then myScrollPane.HPosition = (r.x + PositionInDocument.x * r.width - PositionInScrollPane.x) / (pneMyPages.PrefWidth - vpWidth)

Now I have updated the PDFBoxWrapperExample.zip

Setting the scrollbar width is really a hidden feature!
Note that you can increase the scroll bar size by setting the ScrollPane text size (Extra CSS in the designer):
B4X:
-fx-font-size:  20;

I have found that setting the scrollbar width in code can be done like this:
B4X:
myScrollPane.Style = myScrollPane.Style & "-fx-font-size: 15;"
 
Upvote 0
Top