iOS Question How to create a ScrollView in visual designer

DickD

Active Member
Licensed User
I am trying to set up a scrollview completely in the B4i visual designer for the first time. In B4a I created these in code but never with the designer. I've added a scrollview and then a few textfields and switches to it. Although everything displays properly when I run the program the screen doesn't scroll.

Is there a SIMPLE sample or tutorial somewhere? The B4i beginners guide didn't offer any complete information for doing this. I couldn't find a tutorial.
 

tufanv

Expert
Licensed User
Longtime User
did you set the scrollview1.contentheight to 2000 for example and tried to scroll down ?
I am trying to set up a scrollview completely in the B4i visual designer for the first time. In B4a I created these in code but never with the designer. I've added a scrollview and then a few textfields and switches to it. Although everything displays properly when I run the program the screen doesn't scroll.

Is there a SIMPLE sample or tutorial somewhere? The B4i beginners guide didn't offer any complete information for doing this. I couldn't find a tutorial.
 
Upvote 0

DickD

Active Member
Licensed User
did you set the scrollview1.contentheight to 2000 for example and tried to scroll down ?
Yes. I did that both in the designer and in code. The thing I'm wondering about is panels. Does the scrollview have to be in a panel or vice versa? I think I might be missing something with how the individual fields are mated with the scrollview. Maybe add the fields first then overlay the view on top of it??? Maybe I'm missing a "group" command of some sort.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Attached you find a small project showing a scrollview and its layout defined in the Designer.
You need to define one main layout with the ScrollView and another layout with the ScrollView content.
 

Attachments

  • ScrollViewDesigner.zip
    3.5 KB · Views: 302
Upvote 0

DickD

Active Member
Licensed User
Attached you find a small project showing a scrollview and its layout defined in the Designer.
You need to define one main layout with the ScrollView and another layout with the ScrollView content.
OK that works and I was able to modify it for my needs. But let me get this straight: 1. Create an empty layout that has nothing but a scrollview in it. 2. Create another layout that has a panel to which you can add various other items. 3. Create a variable in code of type ScrollView and another of type Panel. 4. Load the layout containing the panel as shown in the code below. Did I get this right? Are the two lines setting height and width necessary? Aren't they set in the layout files?

Is any of this documented anywhere? I have read every posting on the forum and every tutorial containing the word ScrollView and the Beginner's guide from end to end and don't see this anywhere. Really guys, better documentation please. How about a User's Guide or, even better, a book as with B4A.

B4X:
Private scvTest As ScrollView
Private pnlLayout As Panel
....
scvTest.Panel.LoadLayout("LayoutFileName")
scvTest.ContentHeight = pnlLayout.Height
scvTest.ContentWidth = scvTest.Width
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
1. You can have other objects on the 'main' layout not only the ScrollView.
2. Yes. That's the way I do it.
3. You need the ScrollView variable to be able to load its layout onto the internal panel.
4. Yes. Without horizontal anchors set to BOTH and AutoScale the two lines are not needed.
During my tests I needed to add these two lines to get the display right, with horizontal anchors set to BOTH and AutoScale.
 
Upvote 0
Top