B4A Library A vertical and horizontal scrollable Panel/Layout

Version 1.1 / 2023 - UPDATED

Sometimes the layout size is bigger than your App window this rises the need to attach scrolling/swiping to the layout.

This CustomView solves this problem.
  • Show Layouts bigger than App Window by adding vertical and horizontal scrolling.
  • Automatic detect needed Layout width and hight by child views of the Layout.
  • Published HScrollview and VScrollview Object
  • Published Events of the Scrollviews
Custom Designer Properties:
Layout File, the filename of the layout that hosts the views.
Oversize, Value is in 1/10%. Adds extra space at width and height to insure that all views are visible.

Custom Properties:
LayoutFile, set/load the layout file
HScrollview, public Horizontal Scrollview Object (Inner Panel is hosting the layout)
VScrollview, public Vertical Scrollview

The attached Example Project includes the CustomView as readable class for examinating the code.

Installation:
Copy TD_SwipePanel.b4xlib to your additional libraries folder.
Activate Library Scrollview2D ( get it here: https://www.b4x.com/android/forum/threads/lib-scrollview2d.19268/#content)

Usage:
  1. Activate TD_swipePanel in the libraries window.
  2. Drag CustomView in the Designer onto the windowpage and resize it.
  3. Fill in the Filename in the Designer Custom Property Layout Filename or from code call Custom Property LayoutFile to load the Layout like TD_SwipePanel1.LayoutFile = "ABC.bal".
  4. Grab TD_SwipePanel Events in the parent page as TD_SwipePanel1_HScrollChanged(Position as Int) / TD_SwipePanel1_VScrollChanged(Position as Int)
 

Attachments

  • TD_SwipePanel11_Example.zip
    451.3 KB · Views: 87
  • TD_SwipePanel.b4xlib
    1.5 KB · Views: 83
Last edited:

klaus

Expert
Licensed User
Longtime User
You could also use the ScrollView2D library.
With a HScrollview and a VScrollview you can scroll in one direction only at the same time.
With the ScrollView2D library you can scroll in both direction at the same time.
 
Last edited:

Guenter Becker

Active Member
Licensed User
OK, did'nt no it. But I made an update and now using Scrollview2d. Thank you.
 
Last edited:

byz

Member
Licensed User
I have read your post and currently I am using scrollview to implement it. I need to calculate and set the position of each item. It would be great if customlistview could natively support setting the number of columns and directly adding content, as it would be very convenient to obtain the values of each item.
 

Guenter Becker

Active Member
Licensed User
To the Questiones:
As you see the customview is loading a layout file and this means that it is up to you what you put as child controls in the layout. For example: if you like to have a multicolumn layout feel free to drop a B4XTableView in the Designer.
 
Top