This is actually quite a complicated question which has several solutions depending on how the layout is constructed.
There are (broadly) 2 types of layout:
- Fixed size , where the size of the layout does not vary ( left-right ,up-down anchors are not used)
- varying size, where the size of the controls in the layout, is dependant upon the layout container
Solution for 1:
p.Initialize("")
' Some arbitary size
p.SetLayoutAnimated(0,0,1000dip,2000dip)
p.LoadLayout("ViewEntrySingle")
p.Height = control.top + control.height ' this control is a control at the bottom of the layout
p.width = control.left + control.width ' this control is on the right of the layout
Solution for 2
For 2, you need the to know the container size (sometimes root for b4xpages)
then
p.Initialize("")
p.SetLayoutAnimated(0,0,root.width,root.height)
p.LoadLayout("ViewEntrySingle")
Finally, you may need a panel which can vary in only one of the dimensions.
If you look at the last post in this thread
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
and the code for resizingTextControl you can see how this is done.
EDITS: Pressed send too early.