Scroll View and Scroll View Panel

tomoshea

Member
Licensed User
Longtime User
Hi Erel,
I am new to Basic4Android and I have a question re the Scroll View.
It is giving me an unexpected result.
I have a scrollview sv which is defined using the Designer in Basic4Android for layout Main - I loaded the scrollview panel with another Layout designed in the designer also

using

Activity.LoadLayout("Main")
sv.Panel.LoadLayout("MainPanel")

and in the designer script I have for Main

AutoScaleAll
sv.SetLeftAndRight(0,100%x)
sv.SetTopAndBottom(0,100%y)
sv.Height = 100%y
sv.Width = 100%x

The MainPanel is designed to take up the full screen of a Samsung Galaxy S3 but when I run the app I get a black area at the bottom which hides/covers the bottom part of the MainPanel.
If I change Activity.LoadLayout("Main") to Activity.LoadLayout("MainPanel") I then can see all the MainPanel views with no black area at bottom. So it seems that it is something to do with the scroll view and the way that I have defined it and its panel. Any help would be greatly appreciated.
Thank You.
Kind Regards,
Tom
 

klaus

Expert
Licensed User
Longtime User
What height did you set for the sv.Panel.Height ?
Try to add this line after sv.Panel.LoadLayout
B4X:
sv.Panel.Height = MainPanel.Height
You can remove these two lines from the DesignerScripts
B4X:
sv.Height = 100%y
sv.Width = 100%x
It's already done with SetLeftAndRight and SetTopAndBottom.

Best regards.
 
Upvote 0

tomoshea

Member
Licensed User
Longtime User
Hi Klaus,
Thanks for your reply to my query.

I get a parsing error

Parsing code. Error
Error parsing program.
Error description: Undeclared variable 'mainpanel' is used before it was assigned any value.
Occurred on line: 148
sv.Panel.Height = MainPanel.height

when I try

sv.Panel.Height = MainPanel.height

If I use

vs.panel.height = 100%y instead

the full screen is displayed but when the orientation is changed to landscape scrolling does not work any more.

Kind Regards,
Tom
 
Upvote 0

tomoshea

Member
Licensed User
Longtime User
Hi Klaus,
I have solved the orientation problem by storing the sv.panel height if firsttime is true and
using this to set the sv.panel height when firsttime is false.
So my code now is
Activity.LoadLayout("Main")
sv.Panel.Height = 100%y
sv.Panel.LoadLayout("MainPanel")

If FirstTime Then
panelheight = sv.Panel.Height
Else
sv.Panel.Height = panelheight
End If
Thanks again for your help.
Kind Regards,
Tom
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Sorry my mistake with MainPanel.

What do you have in the MainPanel layout file.
I thought that you had all the views for the ScrollView on a Panel named MainPanel.
The best way is to have in the MainPanel layout file a Panel, for example pnlMain, with all views on it. This Panel can be higher than the screen.
And then in the code set:
sv.Panel.Height = pnlMain.Height

Best regards.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…