Skip to content

Conversation

@zoontek
Copy link
Contributor

@zoontek zoontek commented Aug 13, 2025

Summary:

This PR (initially created for edge-to-edge opt-in support, rebased multiple times) fixes the Dimensions API window values on Android < 15, when edge-to-edge is enabled.

Currently the window height doesn't include the status and navigation bar heights (but it does on Android >= 15):

Screenshot 2025-06-27 at 16 23 02

Using WindowMetricsCalculator from AndroidX:

Screenshot 2025-06-27 at 16 34 01

Fixes #47080

Changelog:

[Android] [Fixed] Fix Dimensions window values on Android < 15 when edge-to-edge is enabled

Test Plan:

Run the example app on an Android < 15 device.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 13, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 13, 2025
@zoontek zoontek force-pushed the fix-dimensions-api branch from 22726c1 to c95b5aa Compare August 13, 2025 17:46
@alanleedev alanleedev requested review from alanleedev, cortinico and javache and removed request for javache August 14, 2025 05:30
@facebook-github-bot
Copy link
Contributor

@alanleedev has imported this pull request. If you are a Meta employee, you can view this in D80237818.

@zoontek zoontek force-pushed the fix-dimensions-api branch from c95b5aa to 47d8ed5 Compare August 20, 2025 10:14
@react-native-bot
Copy link
Collaborator


Warnings
⚠️ ❗ JavaScript API change detected - This PR commits an update to ReactNativeApi.d.ts, indicating a change to React Native's public JavaScript API. Please include a clear changelog message. This change will be subject to extra review.

This change was flagged as: BREAKING

Generated by 🚫 dangerJS against 6b5397a

@facebook-github-bot
Copy link
Contributor

@alanleedev has imported this pull request. If you are a Meta employee, you can view this in D80237818.

@alanleedev
Copy link
Contributor

@zoontek There was a question if we could to" keep initDisplayMetrics as a backwards-compat API and have it call both". I haven't quite figured out the internal crash yet. And it does seem like new API does make things bit more fragile. Do you have any thoughts here?

@zoontek
Copy link
Contributor Author

zoontek commented Sep 2, 2025

@alanleedev One alternative could be to extract the is UI thread method from AndroidX, set both screen and window dimensions when initDisplayMetrics is called, and only update window dimensions when the context passed is UI context. Not perfect as dimensions might be initialize with screen metrics before switching to window ones, but at least it keeps the same API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dimensions.get('window').height not consistent in Android 14 and Android 15

4 participants