Apr 19, 2020 Replies: 2 Lets say that we want to build a layout such as the above where the screen is split into two halves. If we try to build this layout with a single layout file we will quickly meet a problem. We will add this designer script to split the screen: Code: Copy pnlTop.SetTopAndBottom(0, 50%y) pnlBottom.SetTopAndBottom(50%y, 100%y) The problem is that anchors are applied right before the designer script is executed, so the anchors will not be updated when the panels are resized. This means that we will not be able to use anchors and will need to set the size of all the views in the designer script. However there is a better solution, we can split the layout into three nice and clean layout files and load them with: Code: Copy Sub Globals Private WebView1 As WebView Private pnlTop As B4XView Private pnlBottom As B4XView End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("Main") pnlTop.LoadLayout("Top") pnlBottom.LoadLayout("Bottom") End Sub The only designer script needed is for the two panels in the main layout. Note that the variant size doesn't matter. The nested layouts will be resized based on the parent panels sizes. Attachments NestedLayouts.zip NestedLayouts.zip 12.8 KB · Views: 1,013 Click to expand...
Lets say that we want to build a layout such as the above where the screen is split into two halves. If we try to build this layout with a single layout file we will quickly meet a problem. We will add this designer script to split the screen: Code: Copy pnlTop.SetTopAndBottom(0, 50%y) pnlBottom.SetTopAndBottom(50%y, 100%y) The problem is that anchors are applied right before the designer script is executed, so the anchors will not be updated when the panels are resized. This means that we will not be able to use anchors and will need to set the size of all the views in the designer script. However there is a better solution, we can split the layout into three nice and clean layout files and load them with: Code: Copy Sub Globals Private WebView1 As WebView Private pnlTop As B4XView Private pnlBottom As B4XView End Sub Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("Main") pnlTop.LoadLayout("Top") pnlBottom.LoadLayout("Bottom") End Sub The only designer script needed is for the two panels in the main layout. Note that the variant size doesn't matter. The nested layouts will be resized based on the parent panels sizes.
Pflichtfeld Active Member Licensed User Apr 21, 2020 #2 Thank you, is a great help for beginners like me...
klaus Expert Licensed User Longtime User Apr 21, 2020 #3 Very interesting and useful example ! Added to the B4X Visual Designer Booklet for the next update.