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: 5,877
  • Java source - ScrollView2D.zip
    17.6 KB · Views: 1,771
Last edited:

Informatix

Expert
Licensed User
Longtime User
Hi Informatix,

Thanks for the extra info about the ScrollingIsFinished property. Yes, I understand that while dragging the items in the scrollview would need to handle that property to be true as it would not know whether the user was still scrolling. This could be a problem for one of the things that I want to do, but not related to my original post. I have included an example that gives an idea of what I am trying to do, and where I have put a comment about showing the debugger is where I have put a breakpoint. When this breakpoint is reached, I can see that the scrollview is in fact still scrolling on the device. Maybe this is just related to the debugger as it is hard to tell, as the other scrollchanged sub (commented out) I have defined seems to partially work.

What I am trying to do is work out when the scrolling stops, which of the inside panels we are on, so that I can then make sure only that panel is visible. The next challenge will be allowing the drag. Is it possible to still capture the Touch events to see if the finger has been released?

Thanks for any assistance.
The solution is more complicated than you think. Detecting if the finger is up (with the Reflection library) is not enough. I modified your example to show you how to do. I cannot guarantee that is 100% reliable but that seems to work fine.
 

Attachments

  • ScrollViewExample.zip
    7.9 KB · Views: 424

Brian Robinson

Active Member
Licensed User
Longtime User
The solution is more complicated than you think. Detecting if the finger is up (with the Reflection library) is not enough. I modified your example to show you how to do. I cannot guarantee that is 100% reliable but that seems to work fine.

Great work.... After some quick testing it seems to work perfectly. I have modified my code and the snap to position works as I was hoping it would. I really need to start looking how reflection can be applied so I can work things like this out myself. I just don't get time.

Many thanks for such a quick and thorough reply.
 

micheleBr

Member
Licensed User
Longtime User
Hi !
Is it possible use ScrollView2D (horizontal mode) inside a ScrollView (vertical mode)?
tnx!!
 

micheleBr

Member
Licensed User
Longtime User
Yes I know, I would like to build a special layout, something like in yahoo meteo app. (ScrollView2D/horizontally for "next hours section").
 

Attachments

  • horizontal_mode.png
    horizontal_mode.png
    414.9 KB · Views: 381

Micholl

Member
Licensed User
Longtime User
Hi Informatix,
is version 1.1 from this thread the latest version of this lib?
Background: I have faced a problem while using flexible table from Klaus
and surprisingly found a higher version of this lib in my folder which has
caused the problem. Maybe I got this version from ULV?

Michael
 

Informatix

Expert
Licensed User
Longtime User
Hi Informatix,
is version 1.1 from this thread the latest version of this lib?
Background: I have faced a problem while using flexible table from Klaus
and surprisingly found a higher version of this lib in my folder which has
caused the problem. Maybe I got this version from ULV?

Michael
Recent versions of ULV do not include this Scrollview version. It was made for earlier versions of ULV and it is not needed any longer. You should remove it and use the one available in this forum.
 

EnriqueGonzalez

Expert
Licensed User
Longtime User
Hello!

i have question with this lib and with GestureDetector specifically with the drag event. The drag begins, it moves (but way to little, almost nothing) the view(Button) but suddenly stops and begins to scroll the panel.

How can i prevent this from happening? the main idea is that if the users touches the button with the gesturedetector it only moves the button? many many thanks!!
 

Informatix

Expert
Licensed User
Longtime User
Hello!

i have question with this lib and with GestureDetector specifically with the drag event. The drag begins, it moves (but way to little, almost nothing) the view(Button) but suddenly stops and begins to scroll the panel.

How can i prevent this from happening? the main idea is that if the users touches the button with the gesturedetector it only moves the button? many many thanks!!
You can try the DisableTouchEventInterception function of ScrollView2D.
 

EnriqueGonzalez

Expert
Licensed User
Longtime User
The solution with the reflection Library works like a charm, i tried too the DisableTouchEventInterception but it doesnt work, it seems that it works with the parent of the SV2D and not with the childs.

Thanks for answering!
 

corvo

Member
Licensed User
Longtime User
I got a problem whit the sv2d library....i need to create ad horizontal scroll view in a panel whit a graph (ONLY THIS PANEL NEED THE SCROLL, NO THE ENTIRE LAYOUT), this is my code

sv2d.Initialize(1000dip, 500dip, "scvTest")

pnlLine.AddView(sv2d, 0, 0, 100%x, 100%y)
Dim LD As LineData
LD.Initialize
LD.Target = pnlLine
Charts.AddLineColor(LD, Colors.Red)

It don't give any error but don't works, please any idea?
 

Informatix

Expert
Licensed User
Longtime User
I got a problem whit the sv2d library....i need to create ad horizontal scroll view in a panel whit a graph (ONLY THIS PANEL NEED THE SCROLL, NO THE ENTIRE LAYOUT), this is my code

sv2d.Initialize(1000dip, 500dip, "scvTest")

pnlLine.AddView(sv2d, 0, 0, 100%x, 100%y)
Dim LD As LineData
LD.Initialize
LD.Target = pnlLine
Charts.AddLineColor(LD, Colors.Red)

It don't give any error but don't works, please any idea?
If you use only the horizontal scroll, then use the HorizontalScrollView not ScrollView2D.
Anyway, you maybe face an OutOfMemory error. I don't know the Charts library so I cannot help.
 
Top