Setting ScrollView/Panel To Bottom Of Label?

iTzCorky

Member
Licensed User
Longtime User
How do you set a panel to cover the entire screen? I tried to use 100%y but that didnt work and also how do you get a scrollview to resize to the bottom of a label? Here is the code I have tried.

B4X:
Dim stu As StringUtils
   
   lblText.Height = stu.MeasureMultilineTextHeight(lblText, lViewPoke.lblText)
   ScrollView1.Panel.Height = Panel5.Top + Panel5.Height
        Panel5.Height = lblText.Top + lblText.Height

I tried this and the scrollview still has a big white space area below the text. Any ideas?
 

iTzCorky

Member
Licensed User
Longtime User
Assuming that you add the panel manually:
B4X:
Activity.AddView(Panel1, 0, 0, 100%x, 100%y)

What is Panel5?

That did not work panel5 is what holds the label. It is saying The specified child already has a parent. You must call removeView() on the child's parent first. Also what about for the other issue I am having?
 
Last edited:
Upvote 0

Merlot2309

Active Member
Licensed User
Longtime User
Hello,

This should work
B4X:
svInfo.Initialize(0)
   Activity.AddView(svInfo, 1%x, 1%y, 96%x, 22%y)
   lbInfo.Initialize("")
   svInfo.Panel.AddView(lbInfo, 1%x, 0,  95%x, 100%y)
   
   lbInfo.Text = "IMPORTANT: " 

   ht = strUt.MeasureMultilineTextHeight(lbInfo, lbInfo.Text)
   svInfo.Panel.Height = ht + 15%y
   lbInfo.Height = ht + 20%y
   svInfo.ScrollPosition = 0

Success,
Helen.
 
Upvote 0

iTzCorky

Member
Licensed User
Longtime User
Hello,

This should work
B4X:
svInfo.Initialize(0)
   Activity.AddView(svInfo, 1%x, 1%y, 96%x, 22%y)
   lbInfo.Initialize("")
   svInfo.Panel.AddView(lbInfo, 1%x, 0,  95%x, 100%y)
   
   lbInfo.Text = "IMPORTANT: " 

   ht = strUt.MeasureMultilineTextHeight(lbInfo, lbInfo.Text)
   svInfo.Panel.Height = ht + 15%y
   lbInfo.Height = ht + 20%y
   svInfo.ScrollPosition = 0

Success,
Helen.

No that still did not work. That made it worse. All I want is for panel5 to be 100%. Then to have the scrollview change its size to the bottom of lbltext depending on the size of the lbltext.
 
Last edited:
Upvote 0
Top