Natural scrollbar-free scrolling with automatically measured content
For long screens, galleries and dynamic forms. Unlike a native ScrollView where Panel.Height is often maintained manually, RefreshContentSize measures the position and size of the child views. The indicator is hidden by default and the control handles edge-to-edge layouts; vertical and horizontal orientation can be selected in the Designer.
Compared with native ScrollView
No visible scrollbar
ShowScrollBar defaults to False for a clean appearance. Enable it from Designer if desired.
Content measurement
RefreshContentSize measures the farthest bottom/right edge of child views plus padding and trailing space. No manual Panel.Height calculation is required.
Edge-to-edge
Ignores invalid initial layout dimensions and fits the available area. Follow the GetContentRect sample for system bars and IME.
Important: after changing child positions, sizes or visibility directly in Panel, call RefreshContentSize again. Hidden scrollbars do not disable scrolling.
Animated conceptual preview
UIScrollView in action
Illustrative visualization of the behavior, not an exact Android screenshot. The B4A tutorials below show the implementation.
B4A18 Public SubElevateUI
EDGE TO EDGESCROLLBAR: HIDDEN
01 · General information
02 · Technical information
03 · Advanced options
04 · Final preview
Automatically measured content
Search the whole library
Ctrl / ⌘ + K
1. Step-by-step setup
1
Initialize and add UIScrollView to a parent with valid dimensions.
2
Use AddView for automatic recalculation; or Panel.AddView followed by RefreshContentSize.
3
Navigate with ScrollToTop / ScrollToBottom and tune ExtraBottomSpace.
4
With edge-to-edge, use IME.GetContentRect to size your root to the usable area.
2. Practical recipes
1. Scrollbar-free gallery
Sub Globals
Private sv As UIScrollView
Private xui As XUI
End Sub
Sub Activity_Create(FirstTime As Boolean)
sv.Initialize
sv.AddToParent(Activity, 0, 0, 100%x, 100%y)
sv.Color = xui.Color_White
sv.ExtraBottomSpace = 20dip
For i = 0 To 14
Dim lbl As Label
lbl.Initialize("")
lbl.Text = "Section " & (i + 1)
lbl.TextSize = 18
lbl.TextColor = 0xFF0F172A
sv.AddView(lbl, 16dip, i * 72dip, 100%x - 32dip, 60dip)
Next
sv.ScrollToTop
End Sub
2. Edge-to-edge layout with IME
Sub Globals
Private ime As IME
Private Root As B4XView
Private ScrollArea As UIScrollView
Private xui As XUI
End Sub
Sub Activity_Create(FirstTime As Boolean)
ime.Initialize("ime")
Root = xui.CreatePanel("")
Dim safeArea As Rect = ime.GetContentRect
Activity.AddView(Root, safeArea.Left, safeArea.Top, safeArea.Width, safeArea.Height)
ScrollArea.Initialize
ScrollArea.AddToParent(Root, 0, 0, Root.Width, Root.Height)
' Añade vistas a ScrollArea.Panel o mediante ScrollArea.AddView
ScrollArea.RefreshContentSize
End Sub
' Si modificas directamente una vista hija, llama otra vez a:
' ScrollArea.RefreshContentSize
3. Designer properties
Configure these from the B4A Designer when you add the view. Some settings are Designer-only.
Color: fondo del contenedor (transparente por defecto)Padding: espacio interior en dipShowScrollBar: False por defecto (sin barra visible)Orientation: Vertical u Horizontal
4. Every public method explained
18 public method signatures reviewed for this component
Public Sub Initialize
Initializes the container before attaching it.
Public Sub DesignerCreateView(Base As Object, Lbl As Label, Props As Map)
Loads orientation, padding, color and indicator options from Designer.
Public Sub AddToParent(Parent As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)
Attaches the scroll viewport to a parent view.
Public Sub RemoveAllViews
Removes all child views, resets size and returns to the start.
Public Sub RefreshContentSize
Measures each child to its right/bottom edge; sizes Panel and applies optional trailing space.
Public Sub setExtraBottomSpace(Value As Int)
Sets nonnegative trailing space and refreshes the size immediately.
Public Sub getExtraBottomSpace As Int
Returns configured trailing space (10dip by default).
Public Sub AddView(View As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)
Adds a child and recalculates the scrollable area automatically.
Public Sub ScrollTo(Position As Int)
Scrolls to a pixel offset: Y for vertical, X for horizontal.
Public Sub ScrollToTop
Moves to the beginning: top or left.
Public Sub ScrollToBottom
Recalculates and moves to the end: bottom or right.
Public Sub setColor(Color As Int)
Sets the container background color.
Public Sub getColor As Int
Returns the container color.
Public Sub getWidth As Int
Returns visible viewport width, not content width.
Public Sub getHeight As Int
Returns visible viewport height, not content height.
Public Sub getInnerHeight As Int
Returns calculated internal Panel height.
Public Sub getInnerWidth As Int
Returns calculated internal Panel width.
Public Sub getSV As CustomListView
Returns internal CustomListView for advanced integrations.
Integration note
Do not invoke DesignerCreateView directly; the Designer calls it. Preserve the exact capitalization of APIs. For paired set/get methods, use B4A property syntax (e.g. obj.Text = "Hello" and Log(obj.Text)).