- Home /
On Android device Screen.height is returning an incorrect value
In my scene I am trying to center an object and make it's size the height and width of the screen. However when I deploy to a Nexus 5 device that has a resolution of 1920 x 1080 the height and width that is being returned with Screen.height and Screen.width is 1776 x 1080. I've also encountered something similar on Samsung Galaxy S4 and S5 devices. (I don't have the height values that those devices are returning, but if need be I could get them.) It does display correctly on a Nexus 7 device though, so this doesn't appear to be consistent across all devices.
I'm using Unity 4.5.4 and the Nexus 5 is using Android 4.4.2.
Does anyone know of a reason as to why this could be happening?
I have same issue with acer, nexus 7 2013 and nexus 10. I think a reason is undefined behavior for software bottoms in some Android versions.
Answer by Yury-Habets · Mar 27, 2015 at 08:35 AM
First of all, Screen.height returns the window height, not the hardware resolution: http://docs.unity3d.com/ScriptReference/Screen-height.html
Support for immersive fullscreen mode (Android 4.4+) was added in Unity 5. In Unity 4, you got screen height minus the button bar height, so the results looks correct for me. In Unity 5, it returns 1280x768 for my Nexus 4, which also looks correct.
Your answer
Follow this Question
Related Questions
Screen.width and Screen.height sometimes flipped for Android 1 Answer
Android screen orientation: why am I getting wrong screen size values? 1 Answer
Android orientation issue 1 Answer
Do screen.width and screen.height get updated depending on screen orientation on Android? 1 Answer
Screen.width & height not updated after screen rotation 1 Answer