I use B4i 4.30.
I create a layout file containing a panel and a button.
After LoadLayout() is called, I use log() to print out 100%x, 100%y values.
Then I click the button, in the button Click event function, print out the 100%x, 100%y values again.
But the new 100%x, 100%y values are different from the old values before clicking the button.
The new 100%x, 100%y are closed to the panel size.
I have no such problem in B4A.
My log is shown as
===
Copying updated assets files (1)
Application_Start
(1) 100%x=320, 100%y=568
(2) 100%x=320, 100%y=504
Application_Active
In Button1_Click()
Panel1, width=199.3016, height=199.3016
(3) 100%x=199.3016, 100%y=199.3016
===========
The attached is my project file.
if you load every time in resize event your layout you may have multiple views in your app.
resize event will run in many cases like rotating the phone, changing from landscape to portrait because of an incoming call...
you should load your layout in Application_Start event and then handle the resize in resize_event or from the designer.
to get the size of the activity you should do it after resize_event was raised.
as erel said its better to use the page1.rootpanel.width/height for this.
I use forced portrait or landscape modes and then I think the resize only kicks in only once even when leaving the app to a 'rotated mode' and getting back.
I'll need to verify this tho but I never saw my app restart by switching apps.
For protrait/landscape responsive designs you're right for sure.
I use forced portrait or landscape modes and then I think the resize only kicks in only once even when leaving the app to a 'rotated mode' and getting back.
I'll need to verify this tho but I never saw my app restart by switching apps.
For protrait/landscape responsive designs you're right for sure.
start your app and have it on foreground, then perform a call to your phone from another phone and you will see that the resize event will be called again.
its better to have a global variable that will tell you that the resize event was raised and you can ask for it before you perform any resizing in your resize event.
i had the problem that my app was every time resized when an incoming call happened and the app was in foreground.
it happened to one of my users and he reported that everything is very small on the screen and i could not understand what he means.
then he told me that it not happens every time he enters the app. after some investigation i found out that an incoming call will call the resize event.
so i had to put a global variable to ensure that the resize event will only be called once.