Using Rick Byers' demo, you can see what a huge difference this can make when slowly drawing a swirl. Platform.OS = 'android' & Platform.Version >= 29 ?ĭimensions.get('window').height + StatusBar.The result of this change means you have a smoother response to the users gestures as it gives you higher accuracy of the fingers position. I can summarize all this as below: const WINDOW_HEIGHT = What I mentioned above I tested on real devices but this won't be the same on emulator as far as I tested, emulator includes status bar height for versions like 30, 31,33 which are not the case as real devices.If device has notch, that will be included in status bar height as far as I tested and as mentioned in react native docs.Window height includes status bar height (I found this apply on android versions devices below 10) const window_height = Dimensions.get('window').height Window height not includes status bar height (I found this apply on android versions devices 10 and above) so const window_height = Dimensions.get('window').height + Window height is the visible viewport, you can divide this into two parts: Screen_height = window_height + navbar_height, I suspect this may be a bug in React Native rather than an intended behaviour and may change in a future release. In this case the height and width will be greater and the scale will be lower by the same ratio. There's only one exception I'm aware of where window may give values larger than screen: if the app was opened with "display size" or "screen zoom" accessibility setting set high, then, this was set lower with the app still open. So, width and height for window are usually the same size, or, sometimes on Android, smaller than screen. If an element with fixed dimensions fails to scale on changing screen zoom without restarting the app, multiplying those dimensions by Dimensions.get('window').scale / Dimensions.get('screen').scale may help.Įxample image of the Display Size accessibility settings UI from : If the app is restarted, the window scale property will match that of the screen. If an Android device had "screen zoom" or "display size" setting changed in Accessibility settings while the app was open, the scale, width and height properties for window will update to reflect the zoom but the properties for screen will not. This would have been documented by this PR by ThisIsMissEm, but it was closed by Facebook because no-one from Facebook got around to reviewing it.Įxample illustration of Android multi-window mode from : If the app is shown in Android's split screen/multi-window mode, with windows for two apps side by side, window width or height will be lower than for screen and will give the width or height allocated for that app's window. This is illustrated in this answer by RY Zheng which was linked to in an answer to this question which got deleted.Įxample image of an Android system navigation bar from : If an Android device has the device navigation bar visible, the window height (or width when landscape) will be lower than screen height by the height of the navigator. There are at least 3 cases where screen and window may be different: In most cases, width and height for window will be the same size or smaller than screen. On Android, window reflects the section of the total screen made available for this app. I didn't follow back this product pain about orientation changes on Android, so I don't know how rotating your screen affects this. screen: reports entire screen's width/height.window: reports width/height without the soft menu bar.width/height without soft menu bar (so the actual entire screen)Ī quick test on my Android device printing out these values and I was able to confirm that window's height I don't know enough about Android itself, but from what I can gather, it appears that Android can report back two different numbers: If you trace back the history using blame, you'll find this commit on the relevant section of code pointing to this old issue which itself points to this issue about Dimensions reporting different screen heights. If you look at the source of Dimensions, you'll see this comment on line 47: // Screen and window dimensions are different on android The documentation on Dimensions is quite poor ( outstanding issue), so you'll have to dive into the code to understand what is going on.
0 Comments
Leave a Reply. |