useWindowDimensions + translucent system ui returns incorrect dimensions on android
未关闭
还没有人认领这个 Issue。
API: Dimensions
Issue: Author Provided Repro
Needs: Triage :mag:
Platform: Android
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
The window height doesn't include the navigation bar height when it's displayed as "translucent". This also occurs if you enable edge-to-edge mode, which similarly shows the app UI under the system UI.
Steps to reproduce
Install and run the reproducer project
React Native Version
0.73.0
Affected Platforms
Runtime - Android
Output of npx react-native info
System:
OS: macOS 13.6
CPU: (8) arm64 Apple M1 Pro
Memory: 86.08 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.17.1
path: ~/.nvm/versions/node/v18.17.1/bin/node
Yarn:
version: 1.22.19
path: ~/.nvm/versions/node/v18.17.1/bin/yarn
npm:
version: 9.6.7
path: ~/.nvm/versions/node/v18.17.1/bin/npm
Watchman:
version: 2023.09.04.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.11.3
path: /Users/joeporpeglia/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 23.0
- iOS 17.0
- macOS 14.0
- tvOS 17.0
- watchOS 10.0
Android SDK: Not Found
IDEs:
Android Studio: 2022.2 AI-222.4459.24.2221.10121639
Xcode:
version: 15.0/15A240d
path: /usr/bin/xcodebuild
Languages:
Java:
version: 11.0.17
path: /Users/joeporpeglia/.sdkman/candidates/java/current/bin/javac
Ruby:
version: 2.7.5
path: /Users/joeporpeglia/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli": Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.73.0
wanted: 0.73.0
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: Not found
newArchEnabled: false
Stacktrace or Logs
n/a
Reproducer
https://github.com/joeporpeglia/rn-android-window-dimensions-reproducer
Screenshots and Videos
In the screenshots below the height of the blue view is set to useWindowDimensions().height.
Navigation bar height is excluded on all android devices I tested
Status bar height is excluded on Pixel 5 device
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行链接的 rn-android-window-dimensions-reproducer,并检查当 Android 系统 UI 具有半透明效果或采用 edge-to-edge 时,useWindowDimensions 如何报告高度。跟踪 Android 窗口尺寸从 hook 到原生窗口指标的处理过程;当报告的尺寸包含导航栏以及 Android 上受影响的状态栏情况时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, react-native
- 领域
- mobile
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 需要澄清
- 新手友好度
- 45/100