I'm so confused about this... I have more widgets on my page than can fit, so I want to scroll the whole screen. I'm using B4XViews to be cross-platform.
AIUI, on my page/screen, I would have a scrollview (which can fill the screen) and in that scrollview I would load a panel. That panel can be larger than the actual device screen and hold all the widgets. The panel then scrolls inside of the scrollview.
Here's my experiment, which is not working:
- I created a new layout in the designer, with a couple buttons on it, one near the top, and one far down. Saved it as "MainScreenPanel"
- I have a MainScreen layout that's the first one that comes up when my app loads. In that, I added a Scroll View and called it ScrollView1
- Now, in my B4XMainPage file under B4XPage_Appear I added:
The app crashes on startup, and the dump shows...
java.lang.IllegalStateException: ScrollView can host only one direct child
I also tried ScrollView1.RemoveAllViews before the AddView, and no crash, but the scrollview does not appear (the rest of the widgets already on the screen does).
What am I doing wrong here?
Thanks.
AIUI, on my page/screen, I would have a scrollview (which can fill the screen) and in that scrollview I would load a panel. That panel can be larger than the actual device screen and hold all the widgets. The panel then scrolls inside of the scrollview.
Here's my experiment, which is not working:
- I created a new layout in the designer, with a couple buttons on it, one near the top, and one far down. Saved it as "MainScreenPanel"
- I have a MainScreen layout that's the first one that comes up when my app loads. In that, I added a Scroll View and called it ScrollView1
- Now, in my B4XMainPage file under B4XPage_Appear I added:
B4X:
Private ScrollView1 As B4XView
Private Panel1 As B4XView
Panel1 = xui.CreatePanel("MainScreenPanel") ' Will initialize the panel and load the layout with both buttons
Panel1.Height = 1000dip ' Random height for now
ScrollView1.AddView(Panel1, 10dip, 10dip, 100dip, 300dip) ' Add the panel into the scrollview, random dimensions for now
The app crashes on startup, and the dump shows...
java.lang.IllegalStateException: ScrollView can host only one direct child
I also tried ScrollView1.RemoveAllViews before the AddView, and no crash, but the scrollview does not appear (the rest of the widgets already on the screen does).
What am I doing wrong here?
Thanks.
Last edited: