B4J Question Adding a Label to a ScrollPane

wdegler

Active Member
Licensed User
Longtime User
This seems like a very elementary question but I have seen no explanation or example of it:

How can I add a Label to a ScrollPane?
Unlike "Pane", ScrollPane has no "AddNode". None of the available parameters for ScrollPane seem to apply to this. So far, I have only done this using SceneBuilder but now I need to do it programmatically. What is the syntax?

Any help, such as an example and direction to where such information can be found will be much appreciated.
 

wdegler

Active Member
Licensed User
Longtime User
You should add the nodes to the ScrollView inner node:
B4X:
Dim p As Pane = ScrollView.InnerNode
p.AddNode(...)
Thank you, Erel! This is exactly what I needed to know. I assume that "ScrollView" is meant to be of type "ScrollPane. I note that ScrollView is a type in B4A.
 
Upvote 0

zyblux

Member
Licensed User
Longtime User
You are correct.
Hi,
Is there a way to get the scroll pane automatically show the scroller as needed when the content grows by adding controls dymanically @ runtime?

The horiz-scroller only seems to appear in the designer if the content doesn't fit into the scroll pane.

Heres some sample code that shows what I'm trying to do:

Dim p As Pane

p.Initialize("")
p = scrollpane.InnerNode
bread.Initialize("breadA")
p.AddNode(bread, 60, 5, -1, -1)
bread.SetItems(Array("Crumb 1", "Crumb 2", "Crumb 3", "Crumb 3", "Crumb 3", "Crumb 3", "Crumb 3", "Crumb 3", "Crumb 3", "Crumb 3")


It seems the anchorpane (innernode) does not increase in width when large breadcrumb control is added so no horizontal scroller appears :( This means you can't see half the breadcrumbs (unless I maximize the form).

Note: this is not bread crumb specific , the same thing happens when adding say 30 buttons in a row, next to each other.


Thanks
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
You should add the nodes to the ScrollView inner node:
B4X:
Dim p As Pane = ScrollView.InnerNode
p.AddNode(...)


when I try this it always gives an error that the innernode is not initialized, I can't initialize it either by code.

does this only work with code generated scroll panes?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
this works
B4X:
sv.Initialize("")
p.Initialize("")
p=sv.InnerNode

but when I use the designer created one it always fails.

B4X:
p.Initialize("")
p=scrollMap.InnerNode

I just want to add an image to the scrollview
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
Ooooooooooh! you need to set it first

I thought it would set one during the creating and that you had to link it to your own pane.

It works fine now, thanks for the hint!
 
Last edited:
Upvote 0

rbirago

Active Member
Licensed User
Longtime User
I have followed these posts, but in practice I cannot add a Pane to a ScrollPane. Can you please attach a working example (perhaps there is some trick that I've not understood).
thanks
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

pls find attached one way of using the ScrollPane.
For this example, it is filled with Labels via Code (with little gimmick when selecting a label).

Note, that there might be other solutions as well to work with the Scrollpane.
 

Attachments

  • B4JHowToScrollPane.zip
    4.5 KB · Views: 976
Upvote 0
Top