Correct way to link panel and scroll view

sPanel.Initialize("sPanel")
Activity.AddView(sPanel, 0, 72dip, 100%x, Activity.Height - 144dip)

sView.Initialize(1000dip)
sPanel.AddView(sView, 0, 0, 100%x, 100%y)

****

OR

****

sPanel.Initialize("sPanel")
Activity.AddView(sPanel, 0, 72dip, 100%x, Activity.Height - 144dip)

sView.Initialize(1000dip)
Activity.AddView(sView, 0, 72dip, 100%x, Activity.Height - 144dip)
 
Thank you.

So the correct way is to make a scroll view part of a panel. Rather than just putting the scroll view at the same co-ordinates as the panel.

The problem I have now is that altering the height of the scroll view (within the panel) behaves strangely. More specifically, increasing the height of the scroll few, seems to have the opposite effect, i.e. the list in my scroll view gets shorter.

I think I am missing some understanding here.

sView.Initialize(720dip)

...

sView.Height = sView.Height + 72

:BangHead:
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
As Erel already told you, you don't explain what exactly you want to do.
If you want a ScrollView on the Activity:
- Add the ScrollView directly to the activity.
- Add the different Views onto ScrollView.Panel (the internal panel of the ScrollView) or load a layout file with ScrollView.Panel.LoadLayout
- Set the height of ScrollView to the correct value with ScrollView.Panel.Height = xx

Best regards.
 
Upvote 0
Erel/Klaus,

Thank you - you both asked me to explain what I want to achieve. Well quite simply I want a region of the screen (the scrollview/panel), to contain different items, buttons, labels, pictures. But the number of buttons, labels and pictures will vary and will be longer than the physical screen, hence I want scrolling part of the screen to get longer and shorter as I add or remove components.

Is what I want to do possible?

Klaus, based on your advice I now have...

sView.Initialize(0)
Activity.AddView(sView, 0, 72dip, 100%x, Activity.Height - 144dip)

sPanel.Initialize("sPanel")
sPanel = sView.Panel

sView.Panel.Height = 720dip

...then a bit later, if I want to add length to the scroll view, because it has grown, I try this, but it doesn't work...

sView.Panel.Height = sView.Panel.Height + 72dip

...or am I still missing the point? Perhaps you can't add items to the scrolling part of the screen and make its length longer to accommodate these new items.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Is what I want to do possible?
Sure it is !

What are you doing with sPanel ?

Try to add a DoEvents after changing the panel height.
sView.Panel.Height = sView.Panel.Height + 72dip
DoEvents


If you want, you can post your project (or a smaller one showing the problem) as a zip file (IDE menu File / Export As Zip) and I'll have a look at it.
You could also have look at LongTextSimple or ScrollView example with a Panel higher than the screen.

Best regards.
 
Upvote 0
Klaus,

I am going to have to take you up on your offer, here is a cut down version of the code. When you press the buttons at the bottom, the scroll view doesn't get longer or shorter. In this first instance you should see 5 name buttons, but there are actually 10 drawn in the loop. What am I missing?

Sub Globals
Dim sPanel As Panel
Dim sView As ScrollView
Dim ArrayOfButtons(4, 10) As Button
Dim aButton As Button
Dim sButton As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
sView.Initialize(0)
Activity.AddView(sView, 0, 72dip, 100%x, Activity.Height - 144dip)
sPanel.Initialize("sPanel")
sPanel = sView.Panel
sView.Panel.Height = 360dip

For row = 0 To 9
Dim nameButton As Button
nameButton.Initialize("Button")
nameButton.Text = "Player " & (row + 1)
nameButton.Tag = "n" & row

sView.Panel.AddView(nameButton, 72dip, 72dip*row, Activity.Width - 218dip, 70dip)
ArrayOfButtons(0, row) = nameButton
Next

aButton.Initialize("aButton")
sButton.Initialize("sButton")
aButton.Text = "Add"
sButton.Text = "Remove"

Activity.AddView(aButton, ((((Activity.Width / 3) * 1) - (Activity.Width / 3) / 2)) - 45, Activity.Height - 70dip, 90dip, 70dip)
Activity.AddView(sButton, ((((Activity.Width / 3) * 2) - (Activity.Width / 3) / 2)) - 45, Activity.Height - 70dip, 90dip, 70dip)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub aButton_Click
sView.Panel.Height = sView.Panel.Height + 72dip
End Sub

Sub sButton_Click
sView.Panel.Height = sView.Panel.Height - 72dip
End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Why don't you post the project as a zip as requested ?
Looking at the code you posted what is in the Main layout.
These are information nedded to help. That's the reason why I ask the zip file.
I suggested you to add DoEvents, I don't see any.

Best regards.
 
Upvote 0
Klaus,

Sorry - I am a bit new to this. I did try the DoEvents, but it didn't help.

The good news is that I have got it working. If I add something to the panel in the aButton_Click subroutine then increase the height it works!

Thanks for the help and sorry if frustrated you by not posting correctly.
 
Upvote 0
Top