mmieher Active Member Licensed User Longtime User Sep 25, 2021 #1 I have been using B4A since 2012 but still struggle with multiple screen sizes. Have watched the tutorial twenty times. Attached is a simple project. See Trigger_Page1 layout. It works if I set TOP and LEFT as anchors. If I set both HORIZONTAL and VERTICAL anchors, then the button does not show on the screen. Device is Samsung Galaxy S7. It works with horizontal and vertical anchors if Trigger_Page1 is loaded in Activity_Create. Does not work if I call a sub. AppCompat stuff is in the Project because I use it in the App I am trying to make work. Any ideas? Attachments Test.zip Test.zip 10.5 KB · Views: 462
I have been using B4A since 2012 but still struggle with multiple screen sizes. Have watched the tutorial twenty times. Attached is a simple project. See Trigger_Page1 layout. It works if I set TOP and LEFT as anchors. If I set both HORIZONTAL and VERTICAL anchors, then the button does not show on the screen. Device is Samsung Galaxy S7. It works with horizontal and vertical anchors if Trigger_Page1 is loaded in Activity_Create. Does not work if I call a sub. AppCompat stuff is in the Project because I use it in the App I am trying to make work. Any ideas?
klaus Expert Licensed User Longtime User Sep 25, 2021 #2 Move the LoadLayout line after adding the Panel. B4X: Copy Private Sub PageTest '' This DOES NOT Work if Horizontal and Vertical Anchors Set Page1.Initialize("Page1") ' Page1.LoadLayout("Trigger_Page1") Activity.AddView(Page1,0,0,100%x,100%y) Page1.LoadLayout("Trigger_Page1") End Sub Upvote 1
Move the LoadLayout line after adding the Panel. B4X: Copy Private Sub PageTest '' This DOES NOT Work if Horizontal and Vertical Anchors Set Page1.Initialize("Page1") ' Page1.LoadLayout("Trigger_Page1") Activity.AddView(Page1,0,0,100%x,100%y) Page1.LoadLayout("Trigger_Page1") End Sub
mmieher Active Member Licensed User Longtime User Sep 25, 2021 #3 Wow. Thanks, Klaus! Doesn't make intuitive sense, but it worked. I have written dozens of production apps and never had this problem. Upvote 0
Wow. Thanks, Klaus! Doesn't make intuitive sense, but it worked. I have written dozens of production apps and never had this problem.
agraham Expert Licensed User Longtime User Sep 25, 2021 #4 mmieher said: Doesn't make intuitive sense, Click to expand... Why not? You need to add the view so it knows how big it is before you load the layout, otherwise the layout won't size correctly. Upvote 0
mmieher said: Doesn't make intuitive sense, Click to expand... Why not? You need to add the view so it knows how big it is before you load the layout, otherwise the layout won't size correctly.
M Mahares Expert Licensed User Longtime User Sep 25, 2021 #5 mmieher said: Doesn't make intuitive sense Click to expand... If you migrate to B4XPages, you will see that it becomes intuitive and makes a lot more sense. But if you are adding a panel programmatically, you always have to initialize it, then add it to the root or activity, then load the layout onto it in that sequence. Upvote 0
mmieher said: Doesn't make intuitive sense Click to expand... If you migrate to B4XPages, you will see that it becomes intuitive and makes a lot more sense. But if you are adding a panel programmatically, you always have to initialize it, then add it to the root or activity, then load the layout onto it in that sequence.