Android Question [Solved]Label height blocked in a scrollview

ivavilagu

Member
Licensed User
Longtime User
I read all posts about scrollview with labels and I haven´t find the solution. I've got a label in a scrollview and the scrollview into a sliding panel. When I put a large text into the label I can´t scroll, so I can only see a part of the text. I don´t want to resize the label.

B4X:
scroll.Initialize(lbTIEMPO_FINAL_STATS.top - lbOBSERVACIONES_STATS.Top - lbOBSERVACIONES_STATS.Height)
sdPanel_STATS.Panels(0).AddView(scroll,5%x ,lbOBSERVACIONES_STATS.Top + lbOBSERVACIONES_STATS.Height,95%x ,lbTIEMPO_FINAL_STATS.top - lbOBSERVACIONES_STATS.Top)
lbOBSERVACIONES_STATS2.Initialize("lbOBSERVACIONES_STATS2")   
scroll.Panel.AddView(lbOBSERVACIONES_STATS2,0,0,scroll.Width,scroll.Height)
lbOBSERVACIONES_STATS2.Text = "blablablabla blablabla blablabla blablabla blablabla blablabla blablabla blablabla"

What´s wrong?
 
Last edited:

klaus

Expert
Licensed User
Longtime User
You must calculate the Height of the Label lbOBSERVACIONES_STATS2 with the MeasureMultilineTextHeight method from the StringUtils library.
Private ScrollHeight as Int
ScrollHeight = StrUtil.MeasureMultilineTextHeight(lbOBSERVACIONES_STATS2, lbOBSERVACIONES_STATS2.Text)
And then set the Heights.
lbOBSERVACIONES_STATS2.Height
scroll.Panel.Height = ScrollHeight
You could have a look at this example.
 
Upvote 0

ivavilagu

Member
Licensed User
Longtime User
I
You must calculate the Height of the Label lbOBSERVACIONES_STATS2 with the MeasureMultilineTextHeight method from the StringUtils library.
Private ScrollHeight as Int
ScrollHeight = StrUtil.MeasureMultilineTextHeight(lbOBSERVACIONES_STATS2, lbOBSERVACIONES_STATS2.Text)

And then set the Heights.
lbOBSERVACIONES_STATS2.Height
scroll.Panel.Height = ScrollHeight

You could have a look at this example.
I saw the example and tried but with the new height, label overlaps others views. I need to scroll the label within change the label height.
 
Upvote 0

ivavilagu

Member
Licensed User
Longtime User
I don´t know why but today it works perfectly. I was going to pass the zip file and the label height does not change now. o_O

Thanks Klaus!!!
 
Upvote 0
Top