You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On windows the button text change when the application is started, and it shows the real window dimension (e.g. (640,480)), while on android when the application is started it shows (0,0). However when I press the button, my_func works ok and it gives the real window size.
The text was updated successfully, but these errors were encountered:
Initial investigation has revealed that the window size doesn't appear to be available in any capacity until the first onGlobalLayout event.
The same problem doesn't exist on Windows or macOS, as the Window object exists immediately, even if it isn't visible. It doesn't exist on iOS because the window size is determine as a proxy of the device, rather than the layout. However, on Android, the window size is being determined as the size of the ContentFrameLayout, rather than some proxy of the actual device/window.
An immediate workaround in this case is to use a background worker:
This will queue a background task that will be invoked as soon as possible after the creation of the window; but this will occur after the first redraw event, so the window size will exist.
As of #2678, the add_background_task() approach has been deprecated; you can now override on_running() to inject logic that will be executed as soon as the app loop is running.
mhsmith
changed the title
MainWindow.size is (0, 0) until after startup method is complete
On Android, MainWindow.size is (0, 0) until after startup method is complete
Jun 27, 2024
Discussed in #2273
via @cozimus
The following minimum working example work differently on windows and android.
On windows the button text change when the application is started, and it shows the real window dimension (e.g. (640,480)), while on android when the application is started it shows (0,0). However when I press the button,
my_func
works ok and it gives the real window size.The text was updated successfully, but these errors were encountered: