B4J Question scrollpane won't scroll when adding nodes dynamically

le_toubib

Active Member
Licensed User
Longtime User
Hi again
I'm adding an array of nodes into the innerpane of a scroll pane.
but as the inner pane grow taller, the scroll bar is not working, and the pane is not scrollable.
what am I doing wrong ?
 

le_toubib

Active Member
Licensed User
Longtime User
B4X:
    InScroll1.AddNode(spns1(i), 0.05 * MainForm.Width , i * 130 + 80dip + lbls2(i).Height , 0.90 * MainForm.RootPane.Width, 0.07 * MainForm.Height)

InScroll1.PrefHeight= spns1(Q_Count-1).Top + 200dip
scroll1.Pannable=True

in the first line i add a group of spinners (spns1(i) ) on top of each other.

then i set the inner hight of inscroll1 to be 200dip more than the top of the last spinner added
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
B4X:
    InScroll1.AddNode(spns1(i), 0.05 * MainForm.Width , i * 130 + 80dip + lbls2(i).Height , 0.90 * MainForm.RootPane.Width, 0.07 * MainForm.Height)

InScroll1.PrefHeight= spns1(Q_Count-1).Top + 200dip
scroll1.Pannable=True

in the first line i add a group of spinners (spns1(i) ) on top of each other.

then i set the inner hight of inscroll1 to be 200dip more than the top of the last spinner added



no result :-( mmm my error!!


B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
   
    Dim l,t,w,h As Float
   
    Dim ap As ScrollPane
    ap.Initialize("ap")
    Dim pn As Pane = ap.InnerNode
    MainForm.RootPane.AddNode(pn, 0, 0, MainForm.Width/2, MainForm.Height)
   
    l = 10
    t = 0
    w = pn.Width-10
    h = Rnd(32,50)
   
    For i = 0 To 100
        Dim pna As Button
        pna.Initialize("pn")
        pna.Text = "button " & i
        pn.AddNode(pna,l,t,w,h)
        t = t + h + 10
        h = Rnd(100,200)
    Next
   
    ap.Pannable = True
   
End Sub
 
Upvote 0

le_toubib

Active Member
Licensed User
Longtime User
then , at the end u add :
pn.PrefHeight = t + h + 10
this will make it scrollable till 10px after the bottom of the last botton.
 
Upvote 0

ivanomonti

Expert
Licensed User
Longtime User
then , at the end u add :
pn.PrefHeight = t + h + 10
this will make it scrollable till 10px after the bottom of the last botton.

mmmm no result :-(


B4X:
#Region  Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 400
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    MainForm.Show
   
    Dim l,t,w,h As Float
   
    Dim ap As ScrollPane
    ap.Initialize("ap")
    ap.PrefHeight = MainForm.Height
    ap.PrefWidth = MainForm.Width/2
    ap.SetHScrollVisibility("ALWAYS")
    ap.SetVScrollVisibility("ALWAYS")
   
    Dim pn As Pane = ap.InnerNode
    pn.Style = cssIphoneToolsBar
    MainForm.RootPane.AddNode(pn, 0, 0, MainForm.Width/2, MainForm.Height)
   
    l = 10
    t = 10
    w = (MainForm.Width/2)-20
    h = Rnd(32,50)
   
    For i = 0 To 100
        Dim pna As Button
        pna.Initialize("pn")
        pna.Text = "button " & i
        pn.AddNode(pna,l,t,w,h)
        t = t + h + 10
        h = Rnd(100,200)
    Next
   
    pn.PrefHeight = t + h + 10
   
    ap.Pannable = True
   
End Sub

Sub cssIphoneToolsBar As String
    Dim s As String = "-fx-background-color: linear-gradient(#98a8bd 0%, #8195af 25%, #6d86a4 100%);"
    Return s
End Sub
 
Upvote 0
Top