Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

On my iOS emulator they both return the same values.

I understand the difference on a normal browser, but what is the difference on React Native? Are there scenarios where they return differente values?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
819 views
Welcome To Ask or Share your Answers For Others

1 Answer

The documentation on Dimensions is quite poor (outstanding issue), so you'll have to dive into the code to understand what is going on. If you look at the source of Dimensions, you'll see this comment on line 47:

// Screen and window dimensions are different on android

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.

I don't know enough about Android itself, but from what I can gather, it appears that Android can report back two different numbers:

  1. width/height with soft menu bar
  2. width/height without soft menu bar (so the actual entire screen)

A quick test on my Android device printing out these values and I was able to confirm that window's height < screen's height. So in all likelihood, this means:

  • window: reports width/height without the soft menu bar
  • screen: reports entire screen's width/height

I didn't follow back this product pain about orientation changes on Android, so I don't know how rotating your screen affects this.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...