Guenter Becker Active Member Licensed User Longtime User Mar 10, 2023 #1 Hello, today I have a question that knocks my head. Code: Copy Dim P as Panel P.initialize("") P.loadlayout("ABC") This leads me into the problem that the layout is not shown correct because the panel dimension have to be set prior loading. Due to the fact that the layout dimension are depending on the used device and are not set automated after loading the layout there is the question how to get the needed panel dimensions before loading the layout. May be this question is silly but yet I'm lost. Anyone able to help me? Thank you in advance
Hello, today I have a question that knocks my head. Code: Copy Dim P as Panel P.initialize("") P.loadlayout("ABC") This leads me into the problem that the layout is not shown correct because the panel dimension have to be set prior loading. Due to the fact that the layout dimension are depending on the used device and are not set automated after loading the layout there is the question how to get the needed panel dimensions before loading the layout. May be this question is silly but yet I'm lost. Anyone able to help me? Thank you in advance
LucaMs Expert Licensed User Longtime User Mar 10, 2023 #2 You know the views that are part of the layout. I would say to consider the minimum and sufficient dimensions for each type of view; for example, it is reccomended to make them at least 40/50 dip high. By then you should know the minimum panel size you need. Upvote 1
You know the views that are part of the layout. I would say to consider the minimum and sufficient dimensions for each type of view; for example, it is reccomended to make them at least 40/50 dip high. By then you should know the minimum panel size you need.
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Mar 10, 2023 #3 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: B4X: Copy 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 B4X: Copy 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 how to make views align vertically and shrink base on dynamic text content? 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 www.b4x.com and the code for resizingTextControl you can see how this is done. EDITS: Pressed send too early. Upvote 0
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: B4X: Copy 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 B4X: Copy 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 how to make views align vertically and shrink base on dynamic text content? 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 www.b4x.com and the code for resizingTextControl you can see how this is done. EDITS: Pressed send too early.
Erel B4X founder Staff member Licensed User Longtime User Mar 12, 2023 #4 Everything written above is correct. I would add that I never use Panel.Initialize. Instead: Code: Copy Dim p As B4XView = XUI.CreatePanel("") About the question, in B4X it is always the container that sets the size of the child layout. Upvote 0
Everything written above is correct. I would add that I never use Panel.Initialize. Instead: Code: Copy Dim p As B4XView = XUI.CreatePanel("") About the question, in B4X it is always the container that sets the size of the child layout.