B4J Question Adding a scrollpane to tabpane

M.LAZ

Active Member
Licensed User
Longtime User
Hi..
please any help for how to add scrollpane to tabpane
so every tab has it's layout
and i load it with:
TabPane1.LoadLayout("dashboard", "Dashboard")
TabPane1.LoadLayout("activiteis","activiteis")
so how i can add a scrollpane to every tab in tabpane
 
You can add a scrollpane and pane in each layout. The pane contains all the views.
The scrollpane is on top of the pane (move the sptab1 scrollpane below the pntab1 pane).
1759375862406.png
1759376069499.png

The scrollpane can be anchored. If it's not anchored then you need to provide code when the main form resizes.
The size of the pane should be bigger than the size of the scrollpane so you can see the scrolling in action.
Adjust the scrollbar settings when needed: in this example they are always visible.
Here's the code to put everything together:
[CODE lang="b4x" highlight="18-24,27-33"]Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private Button1 As Button
Private Label1 As Label
Private pntab1 As Pane
Private sptab1 As ScrollPane
Private pntab2 As Pane
Private sptab2 As ScrollPane
Private tpmain As TabPane
End Sub
Public Sub Initialize
B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
tpmain.Tabs.Clear
Dim pg1 As TabPage = tpmain.LoadLayout("tab1_layout.bjl","tab1")
pg1.Tag = "tab1"
Dim pg2 As TabPage = tpmain.LoadLayout("tab2_layout.bjl","tab2")
pg2.Tag = "tab2"
sptab1.InnerNode = pntab1
sptab2.InnerNode = pntab2
End Sub
Private Sub B4XPage_Resize (Width As Int, Height As Int)
If pntab1.PrefWidth < Width Then
pntab1.PrefWidth = Width
sptab1.PrefWidth = Width
End If
If pntab1.PrefHeight < Height Then
pntab1.PrefHeight = Height
End If
End Sub[/CODE]
The tab pages are tagged for later reference if needed.
The innernodes of each scrollpane is set to the pane from the same layout.
In this example the resizing is adjusted for the pntab1 pane and the sptab1 scrollpane width is also adjusted.
The source code is attached: testenvironment109.zip
 

Attachments

Upvote 0
Back
Top