Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page.width and page.height not working on apk #4679

Open
1 task done
Jorch98 opened this issue Jan 9, 2025 · 4 comments
Open
1 task done

page.width and page.height not working on apk #4679

Jorch98 opened this issue Jan 9, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@Jorch98
Copy link

Jorch98 commented Jan 9, 2025

Duplicate Check

Describe the bug

page.width and page.height return 0 when the app is build as an apk and run on an android device. Meanwhile on Windows the app runs fine.

Code sample

Code
import flet as ft


def main(page: ft.Page):
    dimensions_text = ft.Container(ft.Text(f"Dimensions: {page.width} : {page.height}", text_align="center"), height= 200, width = 200, alignment=ft.alignment.center)
    page.add(dimensions_text)
    page.update()


ft.app(main)

To reproduce

Run the code on Windows and it will work. Build the apk with flet 0.25.2 and it will fail at displaying the page width and height correctly. The command I am using to build the apk is just flet build apk <app_name>. Am I missing something or is it just a bug?

Expected behavior

No response

Screenshots / Videos

Captures

Android

WhatsApp.Video.2025-01-09.at.17.23.14.mp4

Windows

image

Operating System

Windows

Operating system details

Windows 11 and Android 14

Flet version

0.25.2

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

@FeodorFitsner
Copy link
Contributor

Use page.window.width and page.window.height.

@Jorch98
Copy link
Author

Jorch98 commented Jan 9, 2025

Same issue, but with different values.
Windows:

image

Android:

ef2798d4-934e-40d6-a751-2d1ed365f29a

@FeodorFitsner FeodorFitsner self-assigned this Jan 9, 2025
@FeodorFitsner FeodorFitsner added the bug Something isn't working label Jan 9, 2025
@FeodorFitsner
Copy link
Contributor

OK, will be looking into that.

@Jorch98
Copy link
Author

Jorch98 commented Jan 9, 2025

I run the build with --verbose now to see the extended output and now I can see a warning.
Warning: SDK processing. This version only understands SDK XML versions up to 3 but an SDK XML file of version 4 was encountered. This can happen if you use versions of Android Studio and the command-line tools that were released at different times.
Probably is not related with this issue, as everything else is working fine and I get the apk, but just so you can have all the info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants