Android Question [SOLVED] ScrollView Changes Height When Loading Layout for The Second Time

Uederson Ferreira

Member
Licensed User
Hi all!
I am very new to B4A and I am having some dificulty to do something using scrollview.
I created a big panel with a lot of buttons on it as a layout file using Designer.
I am loading the layout file inside a scrollview.
When I first run the project, the panel is loaded ok inside the scrollview, but if I try to reload the layout, the scrollview height seems to change its value to less.
I attached a modified version of the project where you can hit the "Home" button to reload the layout file.

Thank you in advance!

Uederson
 

Attachments

  • AdroidDev.zip
    11.4 KB · Views: 186

An Schi

Well-Known Member
Licensed User
I haven't run your project cause i'm browsing the forum on the phone....
....but my own 'noob mistakes' come to my mind:
- do you remove the views before (re)loading another layout?
- are you aware that a scrollview has an important value - namely the inner panel height?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
What is btnHome supposed to do?
You should not reload the same layout!
You are mixing up some principles:
- You use AutoScaleAll.
- Then you resize all the views with %x and %y, this overrides AutoScale for the dimensions and position but not for the text size.
- And in the code you set scv.Panel.Height = 2500dip to a given fixed value 2500dip, why? You should use scv.Panel.Height = pnBotoes.Height.

If you turn the device to landscape the layout doesn't look good.
You should use AutoScaleAll and anchors.
You can play a bit with AutoScaleRate(x).
The default value is AutoScaleRate(0.3), you could test it with AutoScaleRate(0.5).

Attached you find a modified version.
 

Attachments

  • AdroidDev1.zip
    10.1 KB · Views: 216
Upvote 0

Uederson Ferreira

Member
Licensed User
I haven't run your project cause i'm browsing the forum on the phone....
....but my own 'noob mistakes' come to my mind:
- do you remove the views before (re)loading another layout?
- are you aware that a scrollview has an important value - namely the inner panel height?
Hi An Schi!
Yes! I remove the views and change the panel height.
Thank you by the reply!

What is btnHome supposed to do?
You should not reload the same layout!
You are mixing up some principles:
- You use AutoScaleAll.
- Then you resize all the views with %x and %y, this overrides AutoScale for the dimensions and position but not for the text size.
- And in the code you set scv.Panel.Height = 2500dip to a given fixed value 2500dip, why? You should use scv.Panel.Height = pnBotoes.Height.

Hi, Klaus!
On my final project I have some layouts.
I need to access every layout and in some point, I will need back to "principal" layout. This is what btnHome do (return to "principal").
I tried scv.Panel.Height = pnBotoes.Height, but when I use it everytime I reload the "pricipal" layout, the height of the panel seems to change, then the buttons change their height too (they grow up).
My app will work only in portrait.
I need learn more about scale.
I will check the tips you gave me!

[EDIT]
I think my problem was with the %x and %y, because now you setted the anchors, when I reload the layout, it is not changing the height!

Thank you so much!
 
Last edited:
Upvote 0
Top