B4A Library [Lib] ScrollView2D

Hello,

Does it need a long explanation ? You can scroll in the two directions.

This lib does not work with Android versions < 2.

v1.01:
I fixed a big bug in the original code.
I added the function SmoothScrollTo.

v1.02:
I restarted from a fresh basis because of the many bugs in the original code. I fixed most of them (now, multitouch events and hardware keys are correctly handled) but a few are left and need more work (sometimes the wrong object get the focus and resizing is not perfectly handled). I noticed by the way that the stock scrollview is bugged and does not set the focus correctly if you move your finger very slowly.
Thanks to Erel, I solved the problem with the B4A documentation.
I added a new function: FullScroll.

v1.03:
I fixed all known bugs (including bugs found in ScrollView & HorizontalScrollView);
I added the scrollbars;
I added three new functions:
- ScrollbarsVisibility
- FadingEdges
- GiveFocusToFirstVisible.

v1.1:
I fixed a problem with events that were not fired if declared in a class;
I added two functions: ScrollingIsFinished and DisableTouchEventInterception.

v1.2:
SV2D appears now as a custom view in the designer with all its properties.

v1.3:
I fixed a bug (SV_2 = SV_1 did not work because the inner panel was declared in the wrong class).

Enjoy,
Fred
 

Attachments

  • ScrollView2D v1.3.zip
    120.5 KB · Views: 3,862
  • Java source - ScrollView2D.zip
    17.6 KB · Views: 761
Last edited:

Robert Valentino

Well-Known Member
Licensed User
Just tried to upgrade from v1.1 to (v1.2 and v1.3) and now when I try and set the ScrollView2D.Panel <height and width>

Crashes

B4X:
  mGrid_Body_SV2D.Panel.Height = CurOffset  + (mFixedHeight - mGridSpacing) + mGridSize
  mGrid_Body_SV2D.Panel.Width  = CurGridBodyLeft + mGridSize


Error occurred on line: 881 (cGrid)
java.lang.NullPointerException
at anywheresoftware.b4a.objects.ViewWrapper.setHeight(ViewWrapper.java:165)
at com.BOBs.GolfScore.cgrid._showgrid(cgrid.java:739)
at com.BOBs.GolfScore.aplayerscoring._drawscoringscreen(aplayerscoring.java:3967)
at com.BOBs.GolfScore.aplayerscoring._createscreen(aplayerscoring.java:3658)
at com.BOBs.GolfScore.aplayerscoring._precreate(aplayerscoring.java:1031)
at com.BOBs.GolfScore.aplayerscoring._activity_create(aplayerscoring.java:773)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)

If I go back to v1.1 everything is fine.

Can I no longer set the Height and Width in the new versions?
 

boten

Active Member
Licensed User
My ScrollView2D's inner panel has labels stacked one below the other.
Each label is of fixed height (lblhgt).

Scrolling vertically (both by slow finger movement AND by fling) can scroll any amount.

What's the best approach to force scroll "by full label height", that is, when a scroll is done - snap VerticalScrollPosition to a integer multiple of lblhgt?
 

W. Graf

Member
Licensed User
Hi Informatix!

ScrollView2D is really great! I like it.
I only have one Problem: I added a seekbar on a ScrollView2D. The touch-event of the seekbar is captured by ScrollView2D. So I'm Scrolling the 2D-area, but not the seekbar. Only in 1 of 10 tries, I'm able to scroll the seekbar.
Is there a possibility, that ScrollView2D only ignores the touch-event, if I touch the seekbar?

Thank you!
 

W. Graf

Member
Licensed User
Thanks for your QUICK(!) answer!!!

If I call ScrollView2D1.DisableTouchEventInterception(True), then nothing changes.
I put this call into the click-event of a button. Both the button and the seekbar is on the ScrollView and both were scrolled by ScrollView. If I click on the button, the function is called, but I still can scroll the ScrollView2D (and I'm not able to scroll the seekbar).

Btw: This call prevents the scroll generally, right? So I will not be able to scroll at all, right?
 

Informatix

Expert
Licensed User
Thanks for your QUICK(!) answer!!!

If I call ScrollView2D1.DisableTouchEventInterception(True), then nothing changes.
I put this call into the click-event of a button. Both the button and the seekbar is on the ScrollView and both were scrolled by ScrollView. If I click on the button, the function is called, but I still can scroll the ScrollView2D (and I'm not able to scroll the seekbar).

Btw: This call prevents the scroll generally, right? So I will not be able to scroll at all, right?
Ah yes you're right. It's for the ScrollView2d parent, not for the children. The only solution is to call something similar in the seekbar code to prevent ScrollView2D from intercepting the touch event.
 

W. Graf

Member
Licensed User
I'm afraid, that Seekbar doesn't offer such a function.

Ok, then I will have to think about a new GUI-design for my app. Thanks for your Reply.
 

RichardHirst

Member
Licensed User
Hello

Please can you tell me if it is possible to Stop the ScrollView2D from moving with code. I see the Enable but not sure what this does.

I want to draw on the canvas while then ScrollView2D remains static, then be able to pan around the panel (which is larger than the screen) using the scroll events etc.

Thank You

Richard
 

Star-Dust

Expert
Licensed User
@Informatix , Why are you releasing the sources of your libraries?
 

DonManfred

Expert
Licensed User

Star-Dust

Expert
Licensed User
:(
 
Top