Hi, I have a stack of views: imageview, label, and a few checkboxes that load its content dynamically (check the picture), how I can align them vertically ? avoiding blank spaces ? shrinking the height of each
Sub RecalculateHeightViews()
Dim su As StringUtils
Dim temp As Int
' recalculate new heights
lblQuestion.height = su.MeasureMultilineTextHeight(lblQuestion,lblQuestion.Text)
chBox1.height = su.MeasureMultilineTextHeight(chBox1,chBox1.Text)+ 10
chBox2.height = su.MeasureMultilineTextHeight(chBox2,chBox2.Text)+ 10
chBox3.height = su.MeasureMultilineTextHeight(chBox3,chBox3.Text)+ 10
chBox4.height = su.MeasureMultilineTextHeight(chBox4,chBox4.Text)+ 10
chBox5.height = su.MeasureMultilineTextHeight(chBox5,chBox5.Text)+ 10
lblHint.height = su.MeasureMultilineTextHeight(lblHint,lblHint.Text)
' recalculate new vertical positions
temp = B4XImageView1.mBase.Top+B4XImageView1.mBase.Height
temp = temp +15
lblQuestion.Top = temp
temp = temp + lblQuestion.Height + 15
chBox1.Top = temp
temp = temp + chBox1.Height + 5
chBox2.Top = temp
temp = temp + chBox2.Height + 5
chBox3.Top = temp
temp = temp + chBox3.Height + 5
chBox4.Top = temp
temp = temp + chBox4.Height + 5
chBox5.Top = temp
temp = temp + chBox5.Height + 5
lblHint.Top = temp
End Sub
So what you're saying is that the text in the labels isn't something known beforehand? That's why you don't already know the height, and that's why you want to calculate the new height so you give all views the correct height (without getting clipped or too much empty space around it)?loading the content of each label and checkbox from a json
yes!! you got itSo what you're saying is that the text in the labels isn't something known beforehand? That's why you don't already know the height, and that's why you want to calculate the new height so you give all views the correct height (without getting clipped or too much empty space around it)?
it is posted on the #4You have still not posted your UI as suggested by Erel in post #2.
My small input is try and use customlistview or scrollview so that in case you calculate the heights and its longer than your users screen, the questions can be able to scroll.
Private p As B4XView = CreateSizingItem(clv.AsView.Width,txt)
clv.Add(p,act)
private Sub CreateSizingItem(wid As Int, txt as string) As B4XView
Private p As B4XView = xui.CreatePanel("")
' The height in Addview is unimportant as it will automatically resize
Root.AddView(p,0,0,wid,300dip)
'Contains a single item Private RTCS As ResizingTextComponent
p.LoadLayout("ResizingTextComponentSingle")
p.RemoveViewFromParent
' Set up some other stuff
RTCS.SetPadding(20dip,10dip,20dip,10dip)
RTCS.SetBackColor(Globals.gcol_midcol)
RTCS.SetCorners(10dip)
' CSBuilder code removed for clarity
RTCS.Text = txt
' Resize the containing panel
p.Height = RTCS.GetHeight
Return p
End Sub
Looks like an interesting concept, but can be more helpful if a working project is included to illustrate and tie all these snippets together.I have taken this from working code, but simplified
True.Looks like an interesting concept, but can be more helpful if a working project is included to illustrate and tie all these snippets together.
I change the text and it doesn't work.Here is a sample project.
No, it isn´t. You should never post in existing threads.If this thread is alive