Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private itemHeight As Double = 40dip
Private verticalScrollbarWidth As Double = 25dip ' Just setting/using this so that the background colours are all visible
Private ScrollPane1 As ScrollPane ' Designer background colour: RED
Private PaneContent As B4XView ' Designer background colour: GREEN
Private PaneItem As B4XView ' Designer background colour: BLUE
Private LabelItem As B4XView ' Designer background colour: WHITE
End Sub
Public Sub Initialize
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
ScrollPane1.LoadLayout("scrollpanecontent", 0, 0)
PaneContent.Width = Root.Width - verticalScrollbarWidth
PaneContent.Height = Root.Height
ScrollPane1.InnerNode.SetSize(Root.Width - verticalScrollbarWidth, Root.Height)
For i = 0 To 99
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, PaneContent.Width, itemHeight)
p.LoadLayout("item")
LabelItem.Text = "Item " & i
PaneContent.AddView(p, 0, i * itemHeight, PaneContent.Width, itemHeight)
Next
' Resize the ScrollPane height
PaneContent.Height = 100 * PaneItem.Height
ScrollPane1.InnerNode.SetSize(Root.Width, PaneContent.Height)
End Sub
Private Sub B4XPage_Resize (Width As Int, Height As Int)
PaneContent.Width = Width
' Innernode (PaneContent - GREEN) now resizes but its contents (BLUE) don't, and they're all anchored
End Sub