Martin Larsen Active Member Licensed User Longtime User Sep 2, 2020 #1 I have this code in Application_Start: B4X: Copy pnlBottomMain.LoadLayout("bottompanel") pnlBottomMain.Height = pnlBottom.height-2 pnlBottomMain.Top = MainPanel.Height - pnlBottomMain.Height However, the layout adjustments are not shown. But if I put the same two lines in a click handler, it works correctly. This tells me that at the time the layout is loaded in the first line, it is not ready yet. I have also tried to put the lines in page_resize but that doesn't work either. Where or how should I make these small adjustments?
I have this code in Application_Start: B4X: Copy pnlBottomMain.LoadLayout("bottompanel") pnlBottomMain.Height = pnlBottom.height-2 pnlBottomMain.Top = MainPanel.Height - pnlBottomMain.Height However, the layout adjustments are not shown. But if I put the same two lines in a click handler, it works correctly. This tells me that at the time the layout is loaded in the first line, it is not ready yet. I have also tried to put the lines in page_resize but that doesn't work either. Where or how should I make these small adjustments?
Erel B4X founder Staff member Licensed User Longtime User Sep 2, 2020 #2 It is something else. It is related to the resize event. Watch the resize event video tutorial: https://www.b4x.com/etp.html The more you can do in the layout files, the simpler things will be. Upvote 0
It is something else. It is related to the resize event. Watch the resize event video tutorial: https://www.b4x.com/etp.html The more you can do in the layout files, the simpler things will be.
ilan Expert Licensed User Longtime User Sep 2, 2020 #3 in application_start the height and weight of the Page are still not known. you need to change the height weight after page_resize was called. (only if you really need to, it would make more sense to do that in the layout file) Upvote 0
in application_start the height and weight of the Page are still not known. you need to change the height weight after page_resize was called. (only if you really need to, it would make more sense to do that in the layout file)
Martin Larsen Active Member Licensed User Longtime User Sep 2, 2020 #4 Erel said: Watch the resize event video tutorial: https://www.b4x.com/etp.html The more you can do in the layout files, the simpler things will be. Click to expand... Thanks, I have seen the video already. I do most of the stuff in the layout designer script, but this I need to do in code. It is because another layout is loaded into a panel on the first layout so I can't address the panels in the script. ilan said: you need to change the height weight after page_resize was called. Click to expand... Thanks. How do I know when page_resize was called? Upvote 0
Erel said: Watch the resize event video tutorial: https://www.b4x.com/etp.html The more you can do in the layout files, the simpler things will be. Click to expand... Thanks, I have seen the video already. I do most of the stuff in the layout designer script, but this I need to do in code. It is because another layout is loaded into a panel on the first layout so I can't address the panels in the script. ilan said: you need to change the height weight after page_resize was called. Click to expand... Thanks. How do I know when page_resize was called?
Erel B4X founder Staff member Licensed User Longtime User Sep 2, 2020 #5 Martin Larsen said: Thanks. How do I know when page_resize was called? Click to expand... It can be called many times. Martin Larsen said: It is because another layout is loaded into a panel on the first layout so I can't address the panels in the script. Click to expand... I'm not sure that I understand but you can usually solve similar issues by splitting the layout into multiple layouts. Upvote 0
Martin Larsen said: Thanks. How do I know when page_resize was called? Click to expand... It can be called many times. Martin Larsen said: It is because another layout is loaded into a panel on the first layout so I can't address the panels in the script. Click to expand... I'm not sure that I understand but you can usually solve similar issues by splitting the layout into multiple layouts.
Alexander Stolte Expert Licensed User Longtime User Sep 2, 2020 #6 and if you put this before you change the top and height? B4X: Copy Wait For B4XPage_Resize (Width As Int, Height As Int) Upvote 0
and if you put this before you change the top and height? B4X: Copy Wait For B4XPage_Resize (Width As Int, Height As Int)
ilan Expert Licensed User Longtime User Sep 2, 2020 #7 this is good if the resize happens only after the application was started. if you put this code in application_start you do get the correct behavior you want BUT resize event will also be called in other scenarios like Incoming call while the app is in the foreground. now the question is will also Apllication_Start be called or only the resize event? if only the resize event then you will need to think again when you need to set those lines. again it is hard to understand what he wants to archive. Upvote 0
this is good if the resize happens only after the application was started. if you put this code in application_start you do get the correct behavior you want BUT resize event will also be called in other scenarios like Incoming call while the app is in the foreground. now the question is will also Apllication_Start be called or only the resize event? if only the resize event then you will need to think again when you need to set those lines. again it is hard to understand what he wants to archive.
Martin Larsen Active Member Licensed User Longtime User Sep 2, 2020 #8 Erel said: you can usually solve similar issues by splitting the layout into multiple layouts. Click to expand... That is what I do. I have a main page and a page with a webview. They use the same bottom menu, so each of the two pages has a panel at the bottom. I then load another layout, called "bottompanel", into that panel. But there is an issue with that. The bottom panel of the two pages has a height of 63. And the layout has the same height. Everything should be fine, but in fact the bottom panel of the two pages become higher than the layout height which looks bad. I have found this issue is caused by AutoScaleAll which for some reason resizes the panel and the layout differently. That is why I need to adjust the bottom panel height after the layout is finished loading. And doing it in application_start doesn't work as correctly stated in #3. If I don't use AutoScaleAll it works as it should. But I like the way the fonts are scaled with AutoScaleAll. Alexander Stolte said: Wait For B4XPage_Resize (Width As Int, Height As Int) Click to expand... Looks promising, I will try that. It's a B4X app btw, but I don't have the issue in Android. Upvote 0
Erel said: you can usually solve similar issues by splitting the layout into multiple layouts. Click to expand... That is what I do. I have a main page and a page with a webview. They use the same bottom menu, so each of the two pages has a panel at the bottom. I then load another layout, called "bottompanel", into that panel. But there is an issue with that. The bottom panel of the two pages has a height of 63. And the layout has the same height. Everything should be fine, but in fact the bottom panel of the two pages become higher than the layout height which looks bad. I have found this issue is caused by AutoScaleAll which for some reason resizes the panel and the layout differently. That is why I need to adjust the bottom panel height after the layout is finished loading. And doing it in application_start doesn't work as correctly stated in #3. If I don't use AutoScaleAll it works as it should. But I like the way the fonts are scaled with AutoScaleAll. Alexander Stolte said: Wait For B4XPage_Resize (Width As Int, Height As Int) Click to expand... Looks promising, I will try that. It's a B4X app btw, but I don't have the issue in Android.
Martin Larsen Active Member Licensed User Longtime User Sep 2, 2020 #9 Martin Larsen said: Looks promising, I will try that. Click to expand... Unfortunately It doesn't work. It waits forever on that line. I call it from application_start. Upvote 0
Martin Larsen said: Looks promising, I will try that. Click to expand... Unfortunately It doesn't work. It waits forever on that line. I call it from application_start.