Jump to content
Sign in to follow this  
Yaron

Detecting when an Android app finishes resizing to fullscreen mode

Recommended Posts

Posted (edited)

I am creating an Android application that scales images based on the device's fullscreen resolution.

To enable fullscreen, I do:
1. In "Project Options / Application / Version Info" I set the theme to "No TitleBar".

2. Set "Form.Fullscreen" to enabled in the main form's "OnCreate" event.

 

However, I'm having problems detecting when my App is finally fullscreen, I suspect there may be a rounding error in Delphi's function, here is the log:
 

05-17 03:56:36.660: I/info(15344): FMX: ZP Remote: ZPR_DBG: Screen Scale                    : 1.3125
05-17 03:56:36.666: I/info(15344): FMX: ZP Remote: ZPR_DBG: IFMXScreenService.GetScreenSize : 1280x736 (with screen scale)
05-17 03:56:36.666: I/info(15344): FMX: ZP Remote: ZPR_DBG: IFMXScreenService.GetScreenSize : 975x561 (original)
05-17 03:56:36.666: I/info(15344): FMX: ZP Remote: ZPR_DBG: Screen                          : 975x561

 

05-17 03:56:36.664: I/info(15344): FMX: ZP Remote: ZPR_DBG: Client                          : 975x537
05-17 03:56:36.724: I/info(15344): FMX: ZP Remote: ZPR_DBG: Client                          : 975x537
05-17 03:56:36.940: I/info(15344): FMX: ZP Remote: ZPR_DBG: Client                          : 975x562

 

The first 4 lines give system detail from IFMXScreenService.GetScreenScale, IFMXScreenService.GetScreenSize and Screen.Width/Screen.Height.

Each "client" line shows the values of "ClientWidth/ClientHeight" on a FormResize event.

 

As you can see, the ClientHeight value is higher than the Screen.Height value, which doesm't make sense.

Edited by Yaron

Share this post


Link to post

Simple...
After the Resize event - wait for application.onIdle - then check clientWight/Height.

 

Frank

Share this post


Link to post
On 6/13/2019 at 8:59 AM, Mavarik said:

Simple...
After the Resize event - wait for application.onIdle - then check clientWight/Height.

 

Frank

That doesn't work, check out this log, a form resize event is triggered AFTER the first OnIdle event.
 

Quote

 

11-26 16:52:11.080    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: FormCreate (before)
11-26 16:52:11.091    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Screen Scale                    "3"
11-26 16:52:11.091    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: clientScreenSize                "1080x2115"
11-26 16:52:11.091    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: IFMXScreenService.GetScreenSize "360x705"
11-26 16:52:11.091    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Screen                          "360x705"
11-26 16:52:11.091    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Display Pixel                   "1080x2340"
11-26 16:52:11.091    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Display Scaled                  "360x780"
11-26 16:52:11.108    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: FormCreate (after)

11-26 16:52:11.108    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: FormResize (before)
11-26 16:52:11.109    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Client "Width x Height"         : 360x678
11-26 16:52:11.110    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Client With Scale               : 1080x2034
11-26 16:52:11.110    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Windows State                   : 0
11-26 16:52:11.110    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: FormResize (after)

11-26 16:52:11.112    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: FormResize (before)
11-26 16:52:11.112    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Client "Width x Height"         : 360x705
11-26 16:52:11.112    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Client With Scale               : 1080x2115
11-26 16:52:11.112    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Windows State                   : 0
11-26 16:52:11.112    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: FormResize (after)

11-26 16:52:11.119    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: FormResize (before)
11-26 16:52:11.119    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Client "Width x Height"         : 360x678
11-26 16:52:11.120    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Client With Scale               : 1080x2034
11-26 16:52:11.120    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Windows State                   : 0
11-26 16:52:11.120    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: FormResize (after)

 

11-26 16:52:11.175    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: OnIdle Event

 

11-26 16:52:11.175    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Resize UI (before)
11-26 16:52:11.309    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Resize UI (after)


11-26 16:52:11.370    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: FormResize (before)
11-26 16:52:11.370    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Client "Width x Height"         : 360x753
11-26 16:52:11.370    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Client With Scale               : 1080x2259
11-26 16:52:11.370    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: Windows State                   : 1
11-26 16:52:11.370    18363    18363    com.inmatrix.ZP_Remote    I    info    FMX: ZP_Remote: ZPR_DBG: FormResize (after)


 

 

Share this post


Link to post

Just for reference, my current logic is to resize the UI after an OnIdle event but not before an "TApplicationEvent.BecameActive" event triggers first.

Seems to work, but I'm not perfectly confident that it works across every device.

 

Oh, you may also notice something odd with the last resize event, the form's WindowState value was changed to "TWindowState.wsMinimized" even though the app is fullscreen.

Perhaps this has something to do with the app being run on a phone with a notch.

Edited by Yaron

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×